Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2022-12-05 05:39:54
Exec Total Coverage
Lines: 6834 11438 59.7%
Functions: 66 105 62.9%
Branches: 4184 9893 42.3%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #ifndef __GTHREAD_HIDE_WIN32API
12 #define __GTHREAD_HIDE_WIN32API 1
13 #endif //prevent indirectly including windows.h
14
15 #include "precompiled.h" //always first
16 11
17 #include <stdio.h>
18 #include <string.h>
19 #include <string>
20 #include <map>
21 #include <vector>
22 #include <assert.h>
23
24
25 #include "metadata/sigs/devsig.h.sig"
26 #include "metadata/sigs/compilersig.h.sig"
27 #include "metadata/versionsig.h"
28 #include "base/zc_alleg.h"
29 #include "base/zdefs.h"
30 #include "base/colors.h"
31 #include "tiles.h"
32 #include "base/zsys.h"
33 #include "qst.h"
34 //#include "zquest.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "font.h"
38 #include "zc_custom.h"
39 #include "sfx.h"
40 #include "md5.h"
41 #include "ffscript.h"
42 #include "particles.h"
43 #include "dialog/alert.h"
44 //FFScript FFCore;
45 extern FFScript FFCore;
46 extern ZModule zcm;
47 extern zcmodule moduledata;
48 extern uint8_t __isZQuest;
49 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
50 extern particle_list particles;
51 extern void setZScriptVersion(int32_t s_version);
52 //FFSCript FFEngine;
53
54 int32_t temp_ffscript_version = 0;
55 static bool read_ext_zinfo = false, read_zinfo = false;
56 static bool loadquest_report = false;
57 static char const* loading_qst_name = NULL;
58 static byte loading_qst_num = 0;
59
60 #ifdef _MSC_VER
61 #define strncasecmp _strnicmp
62 #endif
63
64 #ifndef _AL_MALLOC
65 #define _AL_MALLOC(a) _al_malloc(a)
66 #define _AL_FREE(a) _al_free(a)
67 #endif
68
69 using std::string;
70 using std::pair;
71
72 // extern bool debug;
73 extern int32_t hero_animation_speed; //lower is faster animation
74 extern std::vector<mapscr> TheMaps;
75 extern zcmap *ZCMaps;
76 extern MsgStr *MsgStrings;
77 extern DoorComboSet *DoorComboSets;
78 extern dmap *DMaps;
79 extern newcombo *combobuf;
80 extern byte *colordata;
81 //extern byte *tilebuf;
82 extern tiledata *newtilebuf;
83 extern byte *trashbuf;
84 extern itemdata *itemsbuf;
85 extern wpndata *wpnsbuf;
86 extern comboclass *combo_class_buf;
87 extern guydata *guysbuf;
88 extern ZCHEATS zcheats;
89 extern zinitdata zinit;
90 extern char palnames[MAXLEVELS][17];
91 extern int32_t memrequested;
92 extern char *byte_conversion(int32_t number, int32_t format);
93 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
94 11 string zScript;
95 11 std::map<int32_t, script_slot_data > ffcmap;
96 11 std::map<int32_t, script_slot_data > globalmap;
97 11 std::map<int32_t, script_slot_data > genericmap;
98 11 std::map<int32_t, script_slot_data > itemmap;
99 11 std::map<int32_t, script_slot_data > npcmap;
100 11 std::map<int32_t, script_slot_data > ewpnmap;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
22 std::map<int32_t, script_slot_data > lwpnmap;
102 11 std::map<int32_t, script_slot_data > playermap;
103 11 std::map<int32_t, script_slot_data > dmapmap;
104 11 std::map<int32_t, script_slot_data > screenmap;
105 11 std::map<int32_t, script_slot_data > itemspritemap;
106 11 std::map<int32_t, script_slot_data > comboscriptmap;
107 void free_newtilebuf();
108 bool combosread=false;
109 bool mapsread=false;
110 bool fixffcs=false;
111 bool fixpolsvoice=false;
112
113 11 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
114 11 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
115 11 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
116 11 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
117
118 char qstdat_string[2048] = { 0 };
119
120 static zinfo* load_tmp_zi = NULL;
121
122 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
123 const byte clavio[9]={97,109,111,110,103,117,115,0};
124
125 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
126 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
127
128 extern combo_alias combo_aliases[MAXCOMBOALIASES];
129 extern combo_pool combo_pools[MAXCOMBOPOOLS];
130 const char *qst_error[] =
131 {
132 "OK","File not found","Invalid quest file",
133 "Version not supported","Obsolete version",
134 "Missing new data" , /* but let it pass in ZQuest */
135 "Internal error occurred", "Invalid password",
136 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
137 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
138 };
139
140 //for legacy quests -DD
141 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
142 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
143 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDINSFIRE, ssiFARORESWIND, ssiNAYRUSLOVE, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
144 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
145 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
146 };
147
148 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
149
150
151 void delete_combo_aliases()
152 {
153 for(int32_t j(0); j<256; j++)
154 {
155 if(combo_aliases[j].combos != NULL)
156 {
157 delete[] combo_aliases[j].combos;
158 combo_aliases[j].combos=NULL;
159 }
160
161 if(combo_aliases[j].csets != NULL)
162 {
163 delete[] combo_aliases[j].csets;
164 combo_aliases[j].csets=NULL;
165 }
166 }
167
168 }
169
170 char *byte_conversion(int32_t number, int32_t format)
171 {
172 static char num_str[40];
173
174 if(format==-1) //auto
175 {
176 format=1; //bytes
177
178 if(number>1024)
179 {
180 format=2; //kilobytes
181 }
182
183 if(number>1024*1024)
184 {
185 format=3; //megabytes
186 }
187
188 if(number>1024*1024*1024)
189 {
190 format=4; //gigabytes (dude, what are you doing?)
191 }
192 }
193
194 switch(format)
195 {
196 case 1: //bytes
197 sprintf(num_str,"%db",number);
198 break;
199
200 case 2: //kilobytes
201 sprintf(num_str,"%.2fk",float(number)/1024);
202 break;
203
204 case 3: //megabytes
205 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
206 break;
207
208 case 4: //gigabytes
209 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
210 break;
211
212 default:
213 exit(1);
214 break;
215 }
216
217 return num_str;
218 }
219
220 154 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
221 {
222 static char num_str1[40];
223 static char num_str2[40];
224 static char num_str[80];
225
226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if(format1==-1) //auto
227 {
228 154 format1=1; //bytes
229
230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if(number1>1024)
231 {
232 154 format1=2; //kilobytes
233 154 }
234
235
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 44 times.
154 if(number1>1024*1024)
236 {
237 44 format1=3; //megabytes
238 44 }
239
240
1/2
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
154 if(number1>1024*1024*1024)
241 {
242 format1=4; //gigabytes (dude, what are you doing?)
243 }
244 154 }
245
246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if(format2==-1) //auto
247 {
248 154 format2=1; //bytes
249
250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if(number2>1024)
251 {
252 154 format2=2; //kilobytes
253 154 }
254
255
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 143 times.
154 if(number2>1024*1024)
256 {
257 143 format2=3; //megabytes
258 143 }
259
260
1/2
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
154 if(number2>1024*1024*1024)
261 {
262 format2=4; //gigabytes (dude, what are you doing?)
263 }
264 154 }
265
266
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
154 switch(format1)
267 {
268 case 1: //bytes
269 sprintf(num_str1,"%db",number1);
270 break;
271
272 case 2: //kilobytes
273 110 sprintf(num_str1,"%.2fk",float(number1)/1024);
274 110 break;
275
276 case 3: //megabytes
277 44 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
278 44 break;
279
280 case 4: //gigabytes
281 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
282 break;
283
284 default:
285 exit(1);
286 break;
287 }
288
289
2/5
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 143 times.
✗ Branch 4 not taken.
154 switch(format2)
290 {
291 case 1: //bytes
292 sprintf(num_str2,"%db",number2);
293 break;
294
295 case 2: //kilobytes
296 11 sprintf(num_str2,"%.2fk",float(number2)/1024);
297 11 break;
298
299 case 3: //megabytes
300 143 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
301 143 break;
302
303 case 4: //gigabytes
304 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
305 break;
306
307 default:
308 exit(1);
309 break;
310 }
311
312 154 sprintf(num_str, "%s/%s", num_str1, num_str2);
313 154 return num_str;
314 }
315
316 char *ordinal(int32_t num)
317 {
318 static const char *ending[4] = {"st","nd","rd","th"};
319 static char ord_str[8];
320
321 char *end;
322 int32_t t=(num%100)/10;
323 int32_t n=num%10;
324
325 if(n>=1 && n<4 && t!=1)
326 end = (char *)ending[n-1];
327 else
328 end = (char *)ending[3];
329
330 sprintf(ord_str,"%d%s",num%10000,end);
331 return ord_str;
332 }
333
334 11 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
335 {
336 int32_t ret;
337 11 *version=0;
338 11 *build=0;
339 11 byte temp_map_count=map_count;
340 byte temp_midi_flags[MIDIFLAGS_SIZE];
341 11 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
342
343 zquestheader tempheader;
344
345
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!f)
346 {
347 return qe_invalid;
348 }
349
350 11 ret=readheader(f, &tempheader, true);
351
352
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(ret)
353 {
354 return ret;
355 }
356
357 11 map_count=temp_map_count;
358 11 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
359 11 *version=tempheader.zelda_version;
360 11 *build=tempheader.build;
361 11 return 0;
362 11 }
363
364
365 11 bool find_section(PACKFILE *f, int32_t section_id_requested)
366 {
367
368
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!f)
369 {
370 return false;
371 }
372
373 int32_t section_id_read;
374 11 bool catchup=false;
375 word dummy;
376 byte tempbyte;
377 char tempbuf[65536];
378
379
380
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 switch(section_id_requested)
381 {
382 case ID_RULES:
383 case ID_STRINGS:
384 case ID_MISC:
385 case ID_TILES:
386 case ID_COMBOS:
387 case ID_CSETS:
388 case ID_MAPS:
389 case ID_DMAPS:
390 case ID_DOORS:
391 case ID_ITEMS:
392 case ID_WEAPONS:
393 case ID_COLORS:
394 case ID_ICONS:
395 case ID_INITDATA:
396 case ID_GUYS:
397 case ID_MIDIS:
398 case ID_CHEATS:
399 11 break;
400
401 default:
402 al_trace("Bad section requested!\n");
403 return false;
404 break;
405 }
406
407 dword section_size;
408
409 //section id
410
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_mgetl(&section_id_read,f,true))
411 {
412 return false;
413 }
414
415
1/2
✓ Branch 0 taken 2244 times.
✗ Branch 1 not taken.
2244 while(!pack_feof(f))
416 {
417
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2233 times.
2244 switch(section_id_read)
418 {
419 case ID_RULES:
420 case ID_STRINGS:
421 case ID_MISC:
422 case ID_TILES:
423 case ID_COMBOS:
424 case ID_CSETS:
425 case ID_MAPS:
426 case ID_DMAPS:
427 case ID_DOORS:
428 case ID_ITEMS:
429 case ID_WEAPONS:
430 case ID_COLORS:
431 case ID_ICONS:
432 case ID_INITDATA:
433 case ID_GUYS:
434 case ID_MIDIS:
435 case ID_CHEATS:
436 11 catchup=false;
437 11 break;
438
439 default:
440 2233 break;
441 }
442
443
444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2244 times.
2244 while(catchup)
445 {
446 //section id
447 section_id_read=(section_id_read<<8);
448
449 if(!p_getc(&tempbyte,f,true))
450 {
451 return false;
452 }
453
454 section_id_read+=tempbyte;
455 }
456
457
1/2
✓ Branch 0 taken 2244 times.
✗ Branch 1 not taken.
2244 if(section_id_read==section_id_requested)
458 {
459 return true;
460 }
461 else
462 {
463 //section version info
464
1/2
✓ Branch 0 taken 2244 times.
✗ Branch 1 not taken.
2244 if(!p_igetw(&dummy,f,true))
465 {
466 return false;
467 }
468
469
1/2
✓ Branch 0 taken 2244 times.
✗ Branch 1 not taken.
2244 if(!p_igetw(&dummy,f,true))
470 {
471 return false;
472 }
473
474 //section size
475
1/2
✓ Branch 0 taken 2244 times.
✗ Branch 1 not taken.
2244 if(!p_igetl(&section_size,f,true))
476 {
477 return false;
478 }
479
480 //pack_fseek(f, section_size);
481
2/2
✓ Branch 0 taken 720885 times.
✓ Branch 1 taken 2244 times.
723129 while(section_size>65535)
482 {
483 720885 pfread(tempbuf,65535,f,true);
484 720885 tempbuf[65535]=0;
485 720885 section_size-=65535;
486 }
487
488
2/2
✓ Branch 0 taken 2189 times.
✓ Branch 1 taken 55 times.
2244 if(section_size>0)
489 {
490 55 pfread(tempbuf,section_size,f,true);
491 55 tempbuf[section_size]=0;
492 55 }
493 }
494
495 //section id
496
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2233 times.
2244 if(!p_mgetl(&section_id_read,f,true))
497 {
498 11 return false;
499 }
500 }
501
502 return false;
503 11 }
504
505
506
507
508
509 11 bool valid_zqt(PACKFILE *f)
510 {
511
512 //word tiles_used;
513 //word combos_used;
514 //open the file
515 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!f)
517 return false;
518
519 //for now, everything else is valid
520 11 return true;
521
522 /*int16_t version;
523 byte build;
524
525 //read the version and make sure it worked
526 if(!p_igetw(&version,f,true))
527 {
528 goto error;
529 }
530
531 //read the build and make sure it worked
532 if(!p_getc(&build,f,true))
533 goto error;
534
535 //read the tile info and make sure it worked
536 if(!p_igetw(&tiles_used,f,true))
537 {
538 goto error;
539 }
540
541 for (int32_t i=0; i<tiles_used; i++)
542 {
543 if(!pfread(trashbuf,tilesize(tf4Bit),f,true))
544 {
545 goto error;
546 }
547 }
548
549 //read the combo info and make sure it worked
550 if(!p_igetw(&combos_used,f,true))
551 {
552 goto error;
553 }
554 for (int32_t i=0; i<combos_used; i++)
555 {
556 if(!pfread(trashbuf,sizeof(newcombo),f,true))
557 {
558 goto error;
559 }
560 }
561
562 //read the palette info and make sure it worked
563 for (int32_t i=0; i<48; i++)
564 {
565 if(!pfread(trashbuf,newpdTOTAL,f,true))
566 {
567 goto error;
568 }
569 }
570 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f,true))
571 {
572 goto error;
573 }
574 for (int32_t i=0; i<MAXLEVELS; i++)
575 {
576 if(!pfread(trashbuf,PALNAMESIZE,f,true))
577 {
578 goto error;
579 }
580 }
581
582 //read the sprite info and make sure it worked
583 for (int32_t i=0; i<MAXITEMS; i++)
584 {
585 if(!pfread(trashbuf,sizeof(itemdata),f,true))
586 {
587 goto error;
588 }
589 }
590
591 for (int32_t i=0; i<MAXWPNS; i++)
592 {
593 if(!pfread(trashbuf,sizeof(wpndata),f,true))
594 {
595 goto error;
596 }
597 }
598
599 //read the triforce pieces info and make sure it worked
600 for (int32_t i=0; i<8; ++i)
601 {
602 if(!p_getc(&trashbuf,f,true))
603 {
604 goto error;
605 }
606 }
607
608
609
610 //read the game icons info and make sure it worked
611 for (int32_t i=0; i<4; ++i)
612 {
613 if(!p_igetw(&trashbuf,f,true))
614 {
615 goto error;
616 }
617 }
618
619 //read the misc colors info and map styles info and make sure it worked
620 if(!pfread(trashbuf,sizeof(zcolors),f,true))
621 {
622 goto error;
623 }
624
625 //read the template screens and make sure it worked
626 byte num_maps;
627 if(!p_getc(&num_maps,f,true))
628 {
629 goto error;
630 }
631 for (int32_t i=0; i<TEMPLATES; i++)
632 {
633 if(!pfread(trashbuf,sizeof(mapscr),f,true))
634 {
635 goto error;
636 }
637 }
638 if (num_maps>1) //dungeon templates
639 {
640 for (int32_t i=0; i<TEMPLATES; i++)
641 {
642 if(!pfread(trashbuf,sizeof(mapscr),f,true))
643 {
644 goto error;
645 }
646 }
647 }
648
649 //yay! it worked! close the file and say everything was ok.
650 pack_fclose(f);
651 return true;
652
653 error:
654 pack_fclose(f);
655 return false;*/
656 11 }
657
658 bool valid_zqt(const char *filename)
659 {
660 PACKFILE *f=NULL;
661 bool isvalid;
662 char deletefilename[1024];
663 deletefilename[0]=0;
664 int32_t error;
665 f=open_quest_file(&error, filename, deletefilename, true, true,false);
666
667 if(!f)
668 {
669 // setPackfilePassword(NULL);
670 return false;
671 }
672
673 isvalid=valid_zqt(f);
674
675 if(deletefilename[0])
676 {
677 delete_file(deletefilename);
678 }
679
680 // setPackfilePassword(NULL);
681 return isvalid;
682 }
683
684 73 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, char *deletefilename, bool compressed,bool encrypted, bool show_progress)
685 {
686 char tmpfilename[L_tmpnam];
687 73 temp_name(tmpfilename);
688 char percent_done[30];
689 73 int32_t current_method=0;
690
691 PACKFILE *f;
692 73 const char *passwd= encrypted ? datapwd : "";
693
694 // oldquest flag is set when an unencrypted qst file is suspected.
695 73 bool oldquest = false;
696 int32_t ret;
697
698
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(show_progress)
699 {
700 box_start(1, "Loading Quest", lfont, font, true);
701 }
702
703 73 box_out("Loading Quest: ");
704 //if(strncasecmp(filename, "qst.dat", 7)!=0)
705 //int32_t qstdat_str_size = 0;
706 //for ( int32_t q = 0; q < 255; q++ ) //find the length of the string
707 //{
708 // if ( moduledata.datafiles[qst_dat][q] != 0 ) qstdat_str_size++;
709 // else break;
710 //}
711 //if(strncasecmp(filename, moduledata.datafiles[qst_dat], 7)!=0)
712 73 al_trace("Trying to do strncasecmp() when loading a quest\n");
713 73 int32_t qstdat_filename_size = strlen(moduledata.datafiles[qst_dat]);
714 73 al_trace("Filename size of qst.dat file %s is %d.\n", moduledata.datafiles[qst_dat], qstdat_filename_size);
715 //if(strncasecmp(filename, moduledata.datafiles[qst_dat], qstdat_filename_size)!=0)
716
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(strcmp(filename, moduledata.datafiles[qst_dat])!=0)
717 {
718 73 box_out(filename);
719 73 }
720 else
721 {
722 box_out("new quest"); // Or whatever
723 }
724 73 box_out("...");
725 73 box_eol();
726 73 box_eol();
727
728
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(encrypted)
729 {
730 73 box_out("Decrypting...");
731 73 box_save_x();
732 73 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, strstr(filename, ".dat#")!=NULL, passwd);
733
734
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(ret)
735 {
736 switch(ret)
737 {
738 case 1:
739 box_out("error.");
740 box_eol();
741 box_end(true);
742 *open_error=qe_notfound;
743 return NULL;
744
745 case 2:
746 box_out("error.");
747 box_eol();
748 box_end(true);
749 *open_error=qe_internal;
750 return NULL;
751 // be sure not to delete tmpfilename now...
752 }
753
754 if(ret==5) //old encryption?
755 {
756 current_method++;
757 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
758 box_out(percent_done);
759 box_load_x();
760 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
761 }
762
763 if(ret==5) //old encryption?
764 {
765 current_method++;
766 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
767 box_out(percent_done);
768 box_load_x();
769 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
770 }
771
772 if(ret==5) //old encryption?
773 {
774 current_method++;
775 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
776 box_out(percent_done);
777 box_load_x();
778 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
779 }
780
781 if(ret==5) //old encryption?
782 {
783 current_method++;
784 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
785 box_out(percent_done);
786 box_load_x();
787 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
788 }
789
790 if(ret)
791 {
792 oldquest = true;
793 passwd="";
794 }
795 }
796
797 73 box_out("okay.");
798 73 box_eol();
799 73 }
800 else
801 {
802 oldquest = true;
803 }
804
805 73 box_out("Opening...");
806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
807
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!f)
808 {
809 if((compressed==1)&&(errno==EDOM))
810 {
811 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
812 }
813
814 if(!f)
815 {
816 if(!oldquest)
817 {
818 delete_file(tmpfilename);
819 }
820 box_out("error.");
821 box_eol();
822 box_end(true);
823 *open_error=qe_invalid;
824 return NULL;
825 }
826 }
827
828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 if(!oldquest)
829 {
830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 if(deletefilename)
831 73 sprintf(deletefilename, "%s", tmpfilename);
832 73 }
833
834 73 box_out("okay.");
835 73 box_eol();
836
837 73 return f;
838 73 }
839
840 11 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
841 {
842 char *filename;
843 11 PACKFILE *f=NULL;
844 11 int32_t open_error=0;
845 11 deletefilename[0]=0;
846
847 11 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
848 11 strcat(qstdat_string,"#NESQST_NEW_QST");
849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(Header->templatepath[0]==0)
850 {
851 11 filename=(char *)malloc(2048);
852 //strcpy(filename, "qst.dat#NESQST_NEW_QST");
853 11 strcpy(filename, qstdat_string);
854 11 }
855 else
856 {
857 filename=Header->templatepath;
858 }
859
860 11 f=open_quest_file(&open_error, filename, deletefilename, true, true,false);
861
862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(Header->templatepath[0]==0)
863 {
864 11 free(filename);
865 11 }
866
867
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!f)
868 {
869 return NULL;
870 }
871
872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(validate)
873 {
874
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!valid_zqt(f))
875 {
876 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,lfont);
877 pack_fclose(f);
878
879 //setPackfilePassword(NULL);
880 if(deletefilename[0])
881 {
882 delete_file(deletefilename);
883 }
884
885 return NULL;
886 }
887 11 }
888
889 11 return f;
890 11 }
891
892 11 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
893 {
894 11 combosread=false;
895 11 mapsread=false;
896 11 fixffcs=false;
897
898
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 switch(section_id)
899 {
900 case ID_RULES:
901 case ID_STRINGS:
902 case ID_MISC:
903 case ID_TILES:
904 case ID_COMBOS:
905 case ID_CSETS:
906 case ID_MAPS:
907 case ID_DMAPS:
908 case ID_DOORS:
909 case ID_ITEMS:
910 case ID_WEAPONS:
911 case ID_COLORS:
912 case ID_ICONS:
913 case ID_INITDATA:
914 case ID_GUYS:
915 case ID_MIDIS:
916 case ID_CHEATS:
917 case ID_ITEMDROPSETS:
918 case ID_FAVORITES:
919 11 break;
920
921 default:
922 return false;
923 break;
924 }
925
926 int32_t ret;
927 word version, build;
928 11 PACKFILE *f=NULL;
929
930 char deletefilename[1024];
931 11 deletefilename[0]=0;
932
933 //why is this here?
934 /*
935 if(colordata==NULL)
936 return false;
937 */
938
939 //setPackfilePassword(datapwd);
940 11 f=open_quest_template(Header, deletefilename, validate);
941
942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!f) //no file, nothing to delete
943 {
944 // setPackfilePassword(NULL);
945 return false;
946 }
947
948 11 ret=get_version_and_build(f, &version, &build);
949
950
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
11 if(ret||(version==0))
951 {
952 pack_fclose(f);
953
954 if(deletefilename[0])
955 {
956 delete_file(deletefilename);
957 }
958
959 // setPackfilePassword(NULL);
960 return false;
961 }
962
963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!find_section(f, section_id))
964 {
965 11 al_trace("Can't find section!\n");
966 11 pack_fclose(f);
967
968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(deletefilename[0])
969 {
970 11 delete_file(deletefilename);
971 11 }
972
973 //setPackfilePassword(NULL);
974 11 return false;
975 }
976
977 switch(section_id)
978 {
979 case ID_RULES:
980 //rules
981 ret=readrules(f, Header, true);
982 break;
983
984 case ID_STRINGS:
985 //strings
986 ret=readstrings(f, Header, true);
987 break;
988
989 case ID_MISC:
990 //misc data
991 ret=readmisc(f, Header, Misc, true);
992 break;
993
994 case ID_TILES:
995 //tiles
996 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true, true);
997 break;
998
999 case ID_COMBOS:
1000 //combos
1001 clear_combos();
1002 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS, true);
1003 combosread=true;
1004 break;
1005
1006 case ID_COMBOALIASES:
1007 //combos
1008 ret=readcomboaliases(f, Header, version, build, true);
1009 break;
1010
1011 case ID_CSETS:
1012 //color data
1013 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL, true);
1014 break;
1015
1016 case ID_MAPS:
1017 //maps
1018 ret=readmaps(f, Header, true);
1019 mapsread=true;
1020 break;
1021
1022 case ID_DMAPS:
1023 //dmaps
1024 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS, true);
1025 break;
1026
1027 case ID_DOORS:
1028 //door combo sets
1029 ret=readdoorcombosets(f, Header, true);
1030 break;
1031
1032 case ID_ITEMS:
1033 //items
1034 ret=readitems(f, version, build, true);
1035 break;
1036
1037 case ID_WEAPONS:
1038 //weapons
1039 ret=readweapons(f, Header, true);
1040 break;
1041
1042 case ID_COLORS:
1043 //misc. colors
1044 ret=readmisccolors(f, Header, Misc, true);
1045 break;
1046
1047 case ID_ICONS:
1048 //game icons
1049 ret=readgameicons(f, Header, Misc, true);
1050 break;
1051
1052 case ID_INITDATA:
1053 //initialization data
1054 ret=readinitdata(f, Header, true);
1055 break;
1056
1057 case ID_GUYS:
1058 //guys
1059 ret=readguys(f, Header, true);
1060 break;
1061
1062 case ID_MIDIS:
1063 //midis
1064 ret=readtunes(f, Header, tunes, true);
1065 break;
1066
1067 case ID_CHEATS:
1068 //cheat codes
1069 ret=readcheatcodes(f, Header, true);
1070 break;
1071
1072 case ID_ITEMDROPSETS:
1073 //item drop sets
1074 // Why is this one commented out?
1075 //ret=readitemdropsets(f, (int32_t)version, (word)build, true);
1076 break;
1077
1078 case ID_FAVORITES:
1079 // favorite combos and aliases
1080 ret=readfavorites(f, version, build, true);
1081 break;
1082
1083 default:
1084 ret=-1;
1085 break;
1086 }
1087
1088 pack_fclose(f);
1089
1090 if(deletefilename[0])
1091 {
1092 delete_file(deletefilename);
1093 }
1094
1095 //setPackfilePassword(NULL);
1096 if(!ret)
1097 {
1098 return true;
1099 }
1100
1101 return false;
1102 11 }
1103
1104 bool init_tiles(bool validate, zquestheader *Header)
1105 {
1106 return init_section(Header, ID_TILES, NULL, NULL, validate);
1107 }
1108
1109 bool init_combos(bool validate, zquestheader *Header)
1110 {
1111 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1112 }
1113
1114 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1115 {
1116 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1117 }
1118
1119 62 void init_spritelists()
1120 {
1121
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if(FFCore.quest_format[vZelda] < 0x255)
1122 {
1123 59 guys.setMax(255);
1124 59 items.setMax(255);
1125 59 Ewpns.setMax(255);
1126 59 Lwpns.setMax(255);
1127 59 Sitems.setMax(255);
1128 59 chainlinks.setMax(255);
1129 59 decorations.setMax(255);
1130 59 particles.setMax(255);
1131 59 }
1132 else
1133 {
1134 3 guys.setMax(255);
1135 3 items.setMax(255);
1136 3 Ewpns.setMax(255);
1137 3 Lwpns.setMax(255);
1138 3 Sitems.setMax(255);
1139 3 chainlinks.setMax(255);
1140 3 decorations.setMax(255);
1141 3 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1142 }
1143 62 }
1144
1145 11 bool reset_items(bool validate, zquestheader *Header)
1146 {
1147 11 bool ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1148
1149 //Ignore this, but don't remove it
1150 /*
1151 if (ret)
1152 for(int32_t i=0; i<MAXITEMS; i++)
1153 {
1154 reset_itembuf(&itemsbuf[i], i);
1155 }
1156 */
1157
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1158
1159 11 return ret;
1160 }
1161
1162 bool reset_guys()
1163 {
1164 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1165 init_guys(V_GUYS);
1166 return true;
1167 }
1168
1169 bool reset_wpns(bool validate, zquestheader *Header)
1170 {
1171 bool ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1172
1173 for(int32_t i=0; i<WPNCNT; i++)
1174 reset_weaponname(i);
1175
1176 return ret;
1177 }
1178
1179 bool reset_mapstyles(bool validate, miscQdata *Misc)
1180 {
1181 Misc->colors.blueframe_tile = 20044;
1182 Misc->colors.blueframe_cset = 0;
1183 Misc->colors.triforce_tile = 23461;
1184 Misc->colors.triforce_cset = 1;
1185 Misc->colors.triframe_tile = 18752;
1186 Misc->colors.triframe_cset = 1;
1187 Misc->colors.overworld_map_tile = 16990;
1188 Misc->colors.overworld_map_cset = 2;
1189 Misc->colors.HCpieces_tile = 21160;
1190 Misc->colors.HCpieces_cset = 8;
1191 Misc->colors.dungeon_map_tile = 19651;
1192 Misc->colors.dungeon_map_cset = 8;
1193 return true;
1194 }
1195
1196 bool reset_doorcombosets(bool validate, zquestheader *Header)
1197 {
1198 return init_section(Header, ID_DOORS, NULL, NULL, validate);
1199 }
1200
1201 11 int32_t get_qst_buffers()
1202 {
1203 11 memrequested+=(sizeof(mapscr)*MAPSCRS);
1204 11 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1205 11 TheMaps.resize(MAPSCRS);
1206
1207
2/2
✓ Branch 0 taken 1496 times.
✓ Branch 1 taken 11 times.
1507 for(int32_t i(0); i<MAPSCRS; i++)
1208 1496 TheMaps[i].zero_memory();
1209
1210 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1211 11 Z_message("OK\n"); // Allocating map buffer...
1212
1213 11 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1214 11 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1215
1216
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1217 return 0;
1218
1219 11 Z_message("OK\n");
1220
1221 // Allocating space for all 65535 strings uses up 10.62MB...
1222 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1223 // (Shoelace's "Hero of Dreams" uses 1415.)
1224 // So let's be a bit generous and allow 4096 initially.
1225 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1226 // I tested it and it worked without flaw on 6/6/11. - L.
1227 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1228 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1229 // See https://discord.com/channels/876899628556091432/992984989073416242
1230 11 msg_strings_size = 8192;
1231 11 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1232 11 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1233
1234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 MsgStrings = new MsgStr[msg_strings_size];
1235
1236 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1237
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11 times.
90123 for(auto q = 0; q < msg_strings_size; ++q)
1238 {
1239 90112 MsgStrings[q].clear();
1240 90112 }
1241 11 Z_message("OK\n"); // Allocating string buffer...
1242
1243 11 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1244 11 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1245
1246
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1247 return 0;
1248
1249 11 Z_message("OK\n"); // Allocating door combo buffer...
1250
1251 11 memrequested+=(sizeof(dmap)*MAXDMAPS);
1252 11 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1253
1254
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1255 return 0;
1256
1257 11 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1258 11 Z_message("OK\n"); // Allocating dmap buffer...
1259
1260 11 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1261 11 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1262
1263
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((combobuf=(newcombo*)malloc(sizeof(newcombo)*MAXCOMBOS))==NULL)
1264 return 0;
1265
1266 11 memset(combobuf, 0, sizeof(newcombo)*MAXCOMBOS);
1267 11 Z_message("OK\n"); // Allocating combo buffer...
1268
1269 11 memrequested+=(psTOTAL255);
1270 11 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1271
1272
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1273 return 0;
1274
1275 11 Z_message("OK\n"); // Allocating color data buffer...
1276
1277 11 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1278 11 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1279
1280 11 free_newtilebuf();
1281
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1282 return 0;
1283
1284 11 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1285 //Z_message("Performed memset on tiles\n");
1286 11 clear_tiles(newtilebuf);
1287 //Z_message("Performed clear_tiles()\n");
1288 11 Z_message("OK\n"); // Allocating tile buffer...
1289
1290
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(is_zquest())
1291 {
1292 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1293 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1294
1295 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1296 return 0;
1297
1298 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1299 clear_tiles(grabtilebuf);
1300 Z_message("OK\n"); // Allocating tile grab buffer...
1301 }
1302
1303 11 memrequested+=(100000);
1304 11 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1305
1306
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((trashbuf=(byte*)malloc(100000))==NULL)
1307 return 0;
1308
1309 11 Z_message("OK\n"); // Allocating trash buffer...
1310
1311 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1312 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1313 // fixed by ensuring there's actually itemdata there.
1314 // If you change this, be sure to update del_qst_buffers, too.
1315
1316 11 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1317 11 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1318
1319
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1320 return 0;
1321
1322 11 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1323 11 itemsbuf++;
1324 11 Z_message("OK\n"); // Allocating item buffer...
1325
1326 11 memrequested+=(sizeof(wpndata)*MAXWPNS);
1327 11 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1328
1329
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1330 return 0;
1331
1332 11 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1333 11 Z_message("OK\n"); // Allocating weapon buffer...
1334
1335 11 memrequested+=(sizeof(guydata)*MAXGUYS);
1336 11 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1337
1338
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1339 return 0;
1340
1341 11 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1342 11 Z_message("OK\n"); // Allocating guy buffer...
1343
1344 11 memrequested+=(sizeof(comboclass)*cMAX);
1345 11 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1346
1347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1348 return 0;
1349
1350 11 Z_message("OK\n"); // Allocating combo class buffer...
1351
1352 11 return 1;
1353 11 }
1354
1355
1356 11 void free_newtilebuf()
1357 {
1358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(newtilebuf)
1359 {
1360 for(int32_t i=0; i<NEWMAXTILES; i++)
1361 if(newtilebuf[i].data)
1362 free(newtilebuf[i].data);
1363
1364 free(newtilebuf);
1365 newtilebuf = 0;
1366 }
1367 11 }
1368
1369 void free_grabtilebuf()
1370 {
1371 if(is_zquest())
1372 {
1373 if(grabtilebuf)
1374 {
1375 for(int32_t i=0; i<NEWMAXTILES; i++)
1376 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1377
1378 free(grabtilebuf);
1379 grabtilebuf = 0;
1380 }
1381 }
1382 }
1383
1384 void del_qst_buffers()
1385 {
1386 al_trace("Cleaning maps. \n");
1387
1388 if(ZCMaps) free(ZCMaps);
1389
1390 if(MsgStrings) delete[] MsgStrings;
1391
1392 if(DoorComboSets) free(DoorComboSets);
1393
1394 if(DMaps) free(DMaps);
1395
1396 if(combobuf) free(combobuf);
1397
1398 if(colordata) free(colordata);
1399
1400 al_trace("Cleaning tile buffers. \n");
1401 free_newtilebuf();
1402 free_grabtilebuf();
1403
1404 al_trace("Cleaning misc. \n");
1405
1406 if(trashbuf) free(trashbuf);
1407
1408 // See get_qst_buffers
1409 if(itemsbuf)
1410 {
1411 itemsbuf--;
1412 free(itemsbuf);
1413 }
1414
1415 if(wpnsbuf) free(wpnsbuf);
1416
1417 if(guysbuf) free(guysbuf);
1418
1419 if(combo_class_buf) free(combo_class_buf);
1420 }
1421
1422 bool init_palnames()
1423 {
1424 // if(palnames==NULL)
1425 // return false;
1426
1427 for(int32_t x=0; x<MAXLEVELS; x++)
1428 {
1429 switch(x)
1430 {
1431 case 0:
1432 sprintf(palnames[x],"Overworld");
1433 break;
1434
1435 case 10:
1436 sprintf(palnames[x],"Caves");
1437 break;
1438
1439 case 11:
1440 sprintf(palnames[x],"Passageways");
1441 break;
1442
1443 default:
1444 sprintf(palnames[x],"%c",0);
1445 break;
1446 }
1447 }
1448
1449 return true;
1450 }
1451
1452 14242 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size, bool keepdata)
1453 {
1454 void *p;
1455
1456
1/2
✓ Branch 0 taken 14242 times.
✗ Branch 1 not taken.
14242 p = _AL_MALLOC(MAX(size, alloc_size));
1457
1458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14242 times.
14242 if(!p)
1459 {
1460 return NULL;
1461 }
1462
1463
1/2
✓ Branch 0 taken 14242 times.
✗ Branch 1 not taken.
14242 if(!pfread(p,size,f,keepdata))
1464 {
1465 _AL_FREE(p);
1466 return NULL;
1467 }
1468
1469
1/2
✓ Branch 0 taken 14242 times.
✗ Branch 1 not taken.
14242 if(pack_ferror(f))
1470 {
1471 _AL_FREE(p);
1472 return NULL;
1473 }
1474
1475 14242 return p;
1476 14242 }
1477
1478 /* read_midi:
1479 * Reads MIDI data from a datafile (this is not the same thing as the
1480 * standard midi file format).
1481 */
1482
1483 1181 static MIDI *read_midi(PACKFILE *f, bool)
1484 {
1485 MIDI *m;
1486 int32_t c;
1487 1181 int16_t divisions=0;
1488 1181 int32_t len=0;
1489
1490 1181 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1491
1492
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(!m)
1493 {
1494 return NULL;
1495 }
1496
1497
2/2
✓ Branch 0 taken 37792 times.
✓ Branch 1 taken 1181 times.
38973 for(c=0; c<MIDI_TRACKS; c++)
1498 {
1499 37792 m->track[c].len = 0;
1500 37792 m->track[c].data = NULL;
1501 37792 }
1502
1503 1181 p_mgetw(&divisions,f,true);
1504 1181 m->divisions=divisions;
1505
1506
2/2
✓ Branch 0 taken 37792 times.
✓ Branch 1 taken 1181 times.
38973 for(c=0; c<MIDI_TRACKS; c++)
1507 {
1508 37792 p_mgetl(&len,f,true);
1509 37792 m->track[c].len=len;
1510
1511
2/2
✓ Branch 0 taken 23550 times.
✓ Branch 1 taken 14242 times.
37792 if(m->track[c].len > 0)
1512 {
1513 14242 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0, true);
1514
1515
1/2
✓ Branch 0 taken 14242 times.
✗ Branch 1 not taken.
14242 if(!m->track[c].data)
1516 {
1517 destroy_midi(m);
1518 return NULL;
1519 }
1520 14242 }
1521 37792 }
1522
1523 LOCK_DATA(m, sizeof(MIDI));
1524
1525
2/2
✓ Branch 0 taken 37792 times.
✓ Branch 1 taken 1181 times.
38973 for(c=0; c<MIDI_TRACKS; c++)
1526 {
1527
2/2
✓ Branch 0 taken 14242 times.
✓ Branch 1 taken 23550 times.
37792 if(m->track[c].data)
1528 {
1529 LOCK_DATA(m->track[c].data, m->track[c].len);
1530 14242 }
1531 37792 }
1532
1533 1181 return m;
1534 1181 }
1535
1536 void clear_combo(int32_t i)
1537 {
1538 combobuf[i].clear();
1539 }
1540
1541 void clear_combos()
1542 {
1543 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1544 clear_combo(tmpcounter);
1545 }
1546
1547 void pack_combos()
1548 {
1549 int32_t di = 0;
1550
1551 for(int32_t si=0; si<1024; si+=2)
1552 combobuf[di++] = combobuf[si];
1553
1554 for(; di<1024; di++)
1555 clear_combo(di);
1556 }
1557
1558 62 void reset_tunes(zctune *tune)
1559 {
1560
2/2
✓ Branch 0 taken 15624 times.
✓ Branch 1 taken 62 times.
15686 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1561 {
1562 15624 tune[i].reset();
1563 15624 }
1564 62 }
1565
1566
1567 /*void reset_midi(zcmidi_ *m)
1568 {
1569 m->title[0]=0;
1570 m->loop=1;
1571 m->volume=144;
1572 m->start=0;
1573 m->loop_start=-1;
1574 m->loop_end=-1;
1575 if(m->midi)
1576 {
1577 destroy_midi(m->midi);
1578 }
1579 m->midi=NULL;
1580 }
1581
1582
1583 void reset_midis(zcmidi_ *m)
1584 {
1585 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1586 {
1587 reset_midi(m+i);
1588 }
1589 }
1590 */
1591
1592 void reset_scr(int32_t scr)
1593 {
1594 /*
1595 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1596 for(unsigned i=0; i<sizeof(mapscr); i++)
1597 *(di++) = 0;
1598 TheMaps[scr].valid=mVERSION;
1599 */
1600
1601 TheMaps[scr].zero_memory();
1602 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1603
1604 for(int32_t i=0; i<6; i++)
1605 {
1606 //these will be uncommented later
1607 //TheMaps[scr].layerxsize[i]=16;
1608 //TheMaps[scr].layerysize[i]=11;
1609 TheMaps[scr].layeropacity[i]=255;
1610 }
1611
1612 TheMaps[scr].valid=mVERSION;
1613
1614 }
1615
1616 /* For reference:
1617
1618 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1619 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1620 */
1621
1622 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1623 {
1624 for(int32_t i=0; i<9; i++)
1625 {
1626 for(int32_t j=0; j<6; j++)
1627 {
1628 if(j<4)
1629 {
1630 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1631 {
1632 return false;
1633 }
1634
1635 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1636 {
1637 return false;
1638 }
1639
1640 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1641 {
1642 return false;
1643 }
1644
1645 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1646 {
1647 return false;
1648 }
1649 }
1650
1651 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1652 {
1653 return false;
1654 }
1655
1656 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1657 {
1658 return false;
1659 }
1660
1661 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1662 {
1663 return false;
1664 }
1665
1666 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1667 {
1668 return false;
1669 }
1670 }
1671
1672 if(i<2)
1673 {
1674 if(a.flags[i]!=b.flags[i])
1675 {
1676 return false;
1677 }
1678
1679 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1680 {
1681 return false;
1682 }
1683
1684 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1685 {
1686 return false;
1687 }
1688
1689 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1690 {
1691 return false;
1692 }
1693
1694 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1695 {
1696 return false;
1697 }
1698 }
1699
1700 if(i<3)
1701 {
1702 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1703 {
1704 return false;
1705 }
1706
1707 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1708 {
1709 return false;
1710 }
1711
1712 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1713 {
1714 return false;
1715 }
1716
1717 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1718 {
1719 return false;
1720 }
1721 }
1722
1723 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1724 {
1725 return false;
1726 }
1727
1728 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1729 {
1730 return false;
1731 }
1732 }
1733
1734 return true;
1735 }
1736
1737 int32_t doortranslations_u[9][4]=
1738 {
1739 {37,38,53,54},
1740 {37,38,39,40},
1741 {37,38,55,56},
1742 {37,38,39,40},
1743 {37,38,53,54},
1744 {37,38,53,54},
1745 {37,38,53,54},
1746 {7,8,23,24},
1747 {7,8,41,42}
1748 };
1749
1750 int32_t doortranslations_d[9][4]=
1751 {
1752 {117,118,133,134},
1753 {135,136,133,134},
1754 {119,120,133,134},
1755 {135,136,133,134},
1756 {117,118,133,134},
1757 {117,118,133,134},
1758 {117,118,133,134},
1759 {151,152,167,168},
1760 {137,138,167,168},
1761 };
1762
1763 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1764 int32_t doortranslations_l[9][6]=
1765 {
1766 {66,67,82,83,98,99},
1767 {66,68,82,84,98,100},
1768 {66,69,82,85,98,101},
1769 {66,68,82,84,98,100},
1770 {66,67,82,83,98,99},
1771 {66,67,82,83,98,99},
1772 {66,67,82,83,98,99},
1773 {64,65,80,81,96,97},
1774 {64,65,80,114,96,97},
1775 };
1776
1777 int32_t doortranslations_r[9][6]=
1778 {
1779
1780 {76,77,92,93,108,109},
1781 {75,77,91,93,107,109},
1782 {74,77,90,93,106,109},
1783 {75,77,91,93,107,109},
1784 {76,77,92,93,108,109},
1785 {76,77,92,93,108,109},
1786 {76,77,92,93,108,109},
1787 {78,79,94,95,110,111},
1788 {78,79,125,95,110,111},
1789 };
1790
1791 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1792 {
1793 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1794 }
1795
1796 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1797 {
1798 //these are here to bypass compiler warnings about unused arguments
1799 map=map;
1800 scr=scr;
1801 pos=pos;
1802
1803 //what does this function do?
1804 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1805 return 2;
1806 }
1807
1808 int32_t MakeDoors(int32_t map, int32_t scr)
1809 {
1810 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1811 {
1812 return 0;
1813 }
1814
1815 DoorComboSet tempdcs;
1816 memset(&tempdcs, 0, sizeof(DoorComboSet));
1817
1818 //up
1819 for(int32_t i=0; i<9; i++)
1820 {
1821 for(int32_t j=0; j<4; j++)
1822 {
1823 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1824 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1825 }
1826 }
1827
1828 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1829 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1830 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1831 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1832 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1833 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1834
1835 //down
1836 for(int32_t i=0; i<9; i++)
1837 {
1838 for(int32_t j=0; j<4; j++)
1839 {
1840 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1841 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1842 }
1843 }
1844
1845 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1846
1847 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1848 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1849 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1850 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1851 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1852
1853 //left
1854 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1855 for(int32_t i=0; i<9; i++)
1856 {
1857 for(int32_t j=0; j<6; j++)
1858 {
1859 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1860 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1861 }
1862 }
1863
1864 for(int32_t j=0; j>6; j++)
1865 {
1866 if((j!=2)&&(j!=3))
1867 {
1868 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1869 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1870 }
1871 }
1872
1873 tempdcs.bombdoorcombo_l[0]=0;
1874 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1875 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1876 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1877 tempdcs.bombdoorcombo_l[2]=0;
1878 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1879 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1880 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1881
1882 //right
1883 for(int32_t i=0; i<9; i++)
1884 {
1885 for(int32_t j=0; j<6; j++)
1886 {
1887 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1888 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1889 }
1890 }
1891
1892 for(int32_t j=0; j>6; j++)
1893 {
1894 if((j!=2)&&(j!=3))
1895 {
1896 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1897 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1898 }
1899 }
1900
1901 tempdcs.bombdoorcombo_r[0]=0;
1902 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1903 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1904 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1905 tempdcs.bombdoorcombo_r[2]=0;
1906 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1907 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1908 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1909
1910 int32_t k;
1911
1912 for(k=0; k<door_combo_set_count; k++)
1913 {
1914 if(DoorComboSets[k]==tempdcs)
1915 {
1916 break;
1917 }
1918 }
1919
1920 if(k==door_combo_set_count)
1921 {
1922 DoorComboSets[k]=tempdcs;
1923 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
1924 ++door_combo_set_count;
1925 }
1926
1927 return k;
1928 /*
1929 doorcombo_u[9][4];
1930 doorcset_u[9][4];
1931 doorcombo_d[9][4];
1932 doorcset_d[9][4];
1933 doorcombo_l[9][6];
1934 doorcset_l[9][6];
1935 doorcombo_r[9][6];
1936 doorcset_r[9][6];
1937 bombdoorcombo_u[2];
1938 bombdoorcset_u[2];
1939 bombdoorcombo_d[2];
1940 bombdoorcset_d[2];
1941 bombdoorcombo_l[3];
1942 bombdoorcset_l[3];
1943 bombdoorcombo_r[3];
1944 bombdoorcset_r[3];
1945 walkthroughcombo[4];
1946 walkthroughcset[4];
1947 */
1948 }
1949
1950 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1951 {
1952 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1953 }
1954
1955 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1956 {
1957
1958 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1959 }
1960
1961 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1962 {
1963 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1964 }
1965
1966
1967 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1968 {
1969 char temp_pwd[30];
1970 memset(temp_pwd,0,30);
1971
1972 if(pwdkey!=0)
1973 {
1974 memcpy(temp_pwd,encrypted_pwd,30);
1975 temp_pwd[29]=0;
1976
1977 for(int32_t i=0; i<30; i++)
1978 {
1979 temp_pwd[i] -= pwdkey;
1980 int32_t t=pwdkey>>15;
1981 pwdkey = (pwdkey<<1)+t;
1982 }
1983 }
1984
1985 memcpy(pwd,temp_pwd,30);
1986 }
1987
1988
1989
1990 bool check_questpwd(zquestheader *Header, char *pwd)
1991 {
1992 #if DEVLEVEL > 3
1993 return true;
1994 #endif
1995
1996 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
1997 cvs_MD5Context ctx;
1998 uint8_t md5sum[16];
1999
2000 cvs_MD5Init(&ctx);
2001 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2002 cvs_MD5Final(md5sum, &ctx);
2003
2004 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2005
2006 }
2007
2008 61 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2009 {
2010 61 zprint2("\n");
2011 61 zprint2("[ZQUEST CREATOR METADATA]\n");
2012
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(qst_num < moduledata.max_quest_files)
2013 zprint2("Loading module quest %d\n", qst_num+1);
2014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(path) zprint2("Loading '%s'\n", path);
2015
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if ( tempheader.new_version_id_main > 0 )
2016 {
2017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(tempheader.new_version_id_fourth > 0)
2018 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2019 tempheader.new_version_id_main,tempheader.new_version_id_second,
2020 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2021 61 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2022 61 tempheader.new_version_id_main,tempheader.new_version_id_second,
2023 61 tempheader.new_version_id_third);
2024 61 }
2025 else
2026 {
2027 switch ( tempheader.zelda_version )
2028 {
2029 case 0x255:
2030 {
2031 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2032 break;
2033 }
2034 case 0x254:
2035 {
2036 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2037 break;
2038 }
2039 case 0x250:
2040 {
2041 switch(tempheader.build)
2042 {
2043 case 19:
2044 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2045 case 20:
2046 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2047 case 21:
2048 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2049 case 22:
2050 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2051 case 23:
2052 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2053 case 24:
2054 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2055 case 25:
2056 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2057 case 26:
2058 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2059 case 27:
2060 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2061 case 28:
2062 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2063 case 29:
2064 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2065 case 30:
2066 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2067 case 31:
2068 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2069 case 32:
2070 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2071 case 33:
2072 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2073 default:
2074 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2075
2076 }
2077 break;
2078 }
2079
2080 case 0x211:
2081 {
2082 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2083 }
2084 case 0x210:
2085 {
2086 zprint2("Last saved in ZQuest Version: 2.10.x");
2087 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2088 break;
2089 }
2090 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2091 case 0x193:
2092 {
2093 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2094 }
2095 case 0x192:
2096 {
2097 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2098 }
2099 case 0x190:
2100 {
2101 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2102 }
2103 case 0x184:
2104 {
2105 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2106 }
2107 case 0x183:
2108 {
2109 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2110 }
2111 case 0x180:
2112 {
2113 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2114 }
2115 default:
2116 {
2117 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2118 }
2119 */
2120 }
2121 }
2122
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
61 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2123 2 zprint2("%s\n", tempheader.getAlphaVerStr());
2124 59 else zprint2("\n");
2125
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 2 times.
61 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2126
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 2 times.
61 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2127
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 2 times.
61 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2128
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 2 times.
61 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2130
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 2 times.
61 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2131 61 zprint2("\n");
2132 61 }
2133
2134 73 int32_t readheader(PACKFILE *f, zquestheader *Header, bool keepdata, byte printmetadata)
2135 {
2136 int32_t dummy;
2137 zquestheader tempheader;
2138 73 memcpy(&tempheader, Header, sizeof(tempheader));
2139 char dummybuf[80];
2140 byte temp_map_count;
2141 byte temp_midi_flags[MIDIFLAGS_SIZE];
2142 word version;
2143 char temp_pwd[30], temp_pwd2[30];
2144 int16_t temp_pwdkey;
2145 cvs_MD5Context ctx;
2146 73 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2147 73 memset(&tempheader, 0, sizeof(tempheader));
2148 73 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2149
2150
2151
2152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f,true)) // first read old header
2153 {
2154 Z_message("Unable to read header string\n");
2155 return qe_invalid;
2156 }
2157
2158 // check header
2159
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2160 {
2161 if(strcmp(tempheader.id_str,QH_IDSTR))
2162 {
2163 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2164 return qe_invalid;
2165 }
2166 }
2167
2168 73 int32_t templatepath_len=0;
2169
2170 73 tempheader.external_zinfo = false;
2171 73 read_zinfo = false;
2172
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2173 {
2174 byte padding;
2175
2176 if(!p_getc(&padding,f,true))
2177 {
2178 return qe_invalid;
2179 }
2180
2181 if(!p_igetw(&tempheader.zelda_version,f,true))
2182 {
2183 return qe_invalid;
2184 }
2185
2186 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2187
2188 if(tempheader.zelda_version > ZELDA_VERSION)
2189 {
2190 return qe_version;
2191 }
2192
2193 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2194
2195 if(strcmp(tempheader.id_str,QH_IDSTR))
2196 {
2197 return qe_invalid;
2198 }
2199
2200 if(bad_version(tempheader.zelda_version))
2201 {
2202 return qe_obsolete;
2203 }
2204
2205 if(!p_igetw(&tempheader.internal,f,true))
2206 {
2207 return qe_invalid;
2208 }
2209
2210 if(!p_getc(&tempheader.quest_number,f,true))
2211 {
2212 return qe_invalid;
2213 }
2214
2215 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2216
2217 if(!pfread(&quest_rules[0],2,f,true))
2218 {
2219 return qe_invalid;
2220 }
2221
2222 if(!p_getc(&temp_map_count,f,true))
2223 {
2224 return qe_invalid;
2225 }
2226
2227 FFCore.quest_format[qMapCount] = temp_map_count;
2228
2229 if(!p_getc(&tempheader.old_str_count,f,true))
2230 {
2231 return qe_invalid;
2232 }
2233
2234 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2235 {
2236 return qe_invalid;
2237 }
2238
2239 if(!pfread(temp_midi_flags,4,f,true))
2240 {
2241 return qe_invalid;
2242 }
2243
2244 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2245 {
2246 return qe_invalid;
2247 }
2248
2249 if(!pfread(dummybuf,14,f,true))
2250 {
2251 return qe_invalid;
2252 }
2253
2254 if(!pfread(&quest_rules[2],2,f,true))
2255 {
2256 return qe_invalid;
2257 }
2258
2259 if(!p_getc(&dummybuf,f,true))
2260 {
2261 return qe_invalid;
2262 }
2263
2264 if(!pfread(tempheader.version,sizeof(tempheader.version),f,true))
2265 {
2266 return qe_invalid;
2267 }
2268
2269 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2270 {
2271 return qe_invalid;
2272 }
2273
2274 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2275 {
2276 return qe_invalid;
2277 }
2278
2279 if(!p_getc(&padding,f,true))
2280 {
2281 return qe_invalid;
2282 }
2283
2284 if(!p_igetw(&temp_pwdkey,f,true))
2285 {
2286 return qe_invalid;
2287 }
2288
2289 if(!pfread(temp_pwd,30,f,true))
2290 {
2291 return qe_invalid;
2292 }
2293
2294 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2295 cvs_MD5Init(&ctx);
2296 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2297 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2298
2299 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2300 {
2301 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2302 // Not anymore...
2303 memset(tempheader.minver,0,9);
2304 tempheader.build=0;
2305 tempheader.use_keyfile=0;
2306 memset(tempheader.old_foo, 0, 9);
2307 }
2308 else
2309 {
2310 if(!pfread(tempheader.minver,sizeof(tempheader.minver),f,true))
2311 {
2312 return qe_invalid;
2313 }
2314
2315 if(!p_getc(&tempheader.build,f,true))
2316 {
2317 return qe_invalid;
2318 }
2319
2320 FFCore.quest_format[vBuild] = tempheader.build;
2321
2322 if(!p_getc(&tempheader.use_keyfile,f,true))
2323 {
2324 return qe_invalid;
2325 }
2326
2327 if(!pfread(dummybuf,9,f,true))
2328 {
2329 return qe_invalid;
2330 }
2331 } // starting at minver
2332
2333 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2334 {
2335 memset(&quest_rules[4],0,16); // word rules3..rules10
2336 }
2337 else
2338 {
2339 if(!pfread(&quest_rules[4],16,f,true)) // read new header additions
2340 {
2341 return qe_invalid; // starting at rules3
2342 }
2343
2344 if(tempheader.zelda_version <= 0x190)
2345 {
2346 set_bit(quest_rules,qr_MEANPLACEDTRAPS,0);
2347 }
2348 }
2349
2350 if((tempheader.zelda_version < 0x192)||
2351 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2352 {
2353 set_bit(quest_rules,qr_BRKNSHLDTILES,(get_bit(quest_rules,qr_BRKBLSHLDS_DEP)));
2354 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2355 }
2356
2357 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2358 {
2359 byte *mf=temp_midi_flags;
2360
2361 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2362 {
2363 mf=(byte*)dummybuf;
2364 }
2365
2366 if(!pfread(mf,32,f,true)) // read new header additions
2367 {
2368 return qe_invalid; // starting at foo2
2369 }
2370
2371 if(!pfread(dummybuf,18,f,true)) // read new header additions
2372 {
2373 return qe_invalid; // starting at foo2
2374 }
2375 }
2376
2377 if((tempheader.zelda_version < 0x192)||
2378 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2379 {
2380 memset(tempheader.templatepath,0,2048);
2381 }
2382 else
2383 {
2384 if(!pfread(tempheader.templatepath,280,f,true)) // read templatepath
2385 {
2386 return qe_invalid;
2387 }
2388 }
2389
2390 if((tempheader.zelda_version < 0x192)||
2391 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2392 {
2393 tempheader.use_keyfile=0;
2394 }
2395 }
2396 else
2397 {
2398 //section id
2399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 if(!p_mgetl(&dummy,f,true))
2400 {
2401 return qe_invalid;
2402 }
2403
2404 //section version info
2405
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!p_igetw(&version,f,true))
2406 {
2407 return qe_invalid;
2408 }
2409
2410 73 FFCore.quest_format[vHeader] = version;
2411
2412
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!p_igetw(&dummy,f,true))
2413 {
2414 return qe_invalid;
2415 }
2416
2417 //section size
2418
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!p_igetl(&dummy,f,true))
2419 {
2420 return qe_invalid;
2421 }
2422
2423 //finally... section data
2424
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!p_igetw(&tempheader.zelda_version,f,true))
2425 {
2426 return qe_invalid;
2427 }
2428
2429 73 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2430
2431 //do some quick checking...
2432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 if(tempheader.zelda_version > ZELDA_VERSION)
2433 {
2434 return qe_version;
2435 }
2436
2437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2438 {
2439 return qe_invalid;
2440 }
2441
2442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 if(bad_version(tempheader.zelda_version))
2443 {
2444 return qe_obsolete;
2445 }
2446
2447
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!p_getc(&tempheader.build,f,true))
2448 {
2449 return qe_invalid;
2450 }
2451
2452 73 FFCore.quest_format[vBuild] = tempheader.build;
2453
2454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 if(version<3)
2455 {
2456 if(!pfread(temp_pwd,30,f,true))
2457 {
2458 return qe_invalid;
2459 }
2460
2461 if(!p_igetw(&temp_pwdkey,f,true))
2462 {
2463 return qe_invalid;
2464 }
2465
2466 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2467 cvs_MD5Init(&ctx);
2468 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2469 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2470 }
2471 else
2472 {
2473
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f,true))
2474 {
2475 return qe_invalid;
2476 }
2477 }
2478
2479
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!p_igetw(&tempheader.internal,f,true))
2480 {
2481 return qe_invalid;
2482 }
2483
2484
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!p_getc(&tempheader.quest_number,f,true))
2485 {
2486 return qe_invalid;
2487 }
2488
2489 73 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2490
2491
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!pfread(tempheader.version,sizeof(tempheader.version),f,true))
2492 {
2493 return qe_invalid;
2494 }
2495
2496 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2497 //needs to be copied as char[9] or stored as a s.str
2498
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!pfread(tempheader.minver,sizeof(tempheader.minver),f,true))
2499 {
2500 return qe_invalid;
2501 }
2502
2503 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2504 //needs to be copied as char[9] or stored as a s.str
2505
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2506 {
2507 return qe_invalid;
2508 }
2509
2510
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2511 {
2512 return qe_invalid;
2513 }
2514
2515
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!p_getc(&tempheader.use_keyfile,f,true))
2516 {
2517 return qe_invalid;
2518 }
2519
2520 /*
2521 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f,true))
2522 {
2523 return qe_invalid;
2524 }
2525 */
2526
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2527 {
2528 return qe_invalid;
2529 }
2530
2531
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!pfread(&dummybuf,4,f,true))
2532 {
2533 return qe_invalid;
2534 }
2535
2536
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2537 {
2538 return qe_invalid;
2539 }
2540
2541
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!pfread(dummybuf,14,f,true))
2542 {
2543 return qe_invalid;
2544 }
2545
2546 73 templatepath_len=sizeof(tempheader.templatepath);
2547
2548
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(version==1)
2549 {
2550 templatepath_len=280;
2551 }
2552
2553
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!pfread(tempheader.templatepath,templatepath_len,f,true))
2554 {
2555 return qe_invalid;
2556 }
2557
2558
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!p_getc(&temp_map_count,f,true))
2559 {
2560 return qe_invalid;
2561 }
2562
2563
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 59 times.
73 if(version>=4)
2564 {
2565
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_igetl(&tempheader.new_version_id_main,f,true))
2566 {
2567 return qe_invalid;
2568 }
2569
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_igetl(&tempheader.new_version_id_second,f,true))
2570 {
2571 return qe_invalid;
2572 }
2573
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_igetl(&tempheader.new_version_id_third,f,true))
2574 {
2575 return qe_invalid;
2576 }
2577
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_igetl(&tempheader.new_version_id_fourth,f,true))
2578 {
2579 return qe_invalid;
2580 }
2581
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_igetl(&tempheader.new_version_id_alpha,f,true))
2582 {
2583 return qe_invalid;
2584 }
2585
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_igetl(&tempheader.new_version_id_beta,f,true))
2586 {
2587 return qe_invalid;
2588 }
2589
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_igetl(&tempheader.new_version_id_gamma,f,true))
2590 {
2591 return qe_invalid;
2592 }
2593
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_igetl(&tempheader.new_version_id_release,f,true))
2594 {
2595 return qe_invalid;
2596 }
2597
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_igetw(&tempheader.new_version_id_date_year,f,true))
2598 {
2599 return qe_invalid;
2600 }
2601
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_getc(&tempheader.new_version_id_date_month,f,true))
2602 {
2603 return qe_invalid;
2604 }
2605
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_getc(&tempheader.new_version_id_date_day,f,true))
2606 {
2607 return qe_invalid;
2608 }
2609
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_getc(&tempheader.new_version_id_date_hour,f,true))
2610 {
2611 return qe_invalid;
2612 }
2613
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_getc(&tempheader.new_version_id_date_minute,f,true))
2614 {
2615 return qe_invalid;
2616 }
2617
2618
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!pfread(tempheader.new_version_devsig,256,f,true))
2619 {
2620 return qe_invalid;
2621 }
2622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2623 strcpy(tempheader.new_version_devsig, "EmilyV99");
2624
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!pfread(tempheader.new_version_compilername,256,f,true))
2625 {
2626 return qe_invalid;
2627 }
2628
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!pfread(tempheader.new_version_compilerversion,256,f,true))
2629 {
2630 return qe_invalid;
2631 }
2632
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!pfread(tempheader.product_name,1024,f,true))
2633 {
2634 return qe_invalid;
2635 }
2636
2637
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_getc(&tempheader.compilerid,f,true))
2638 {
2639 return qe_invalid;
2640 }
2641
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_igetl(&tempheader.compilerversionnumber_first,f,true))
2642 {
2643 return qe_invalid;
2644 }
2645
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_igetl(&tempheader.compilerversionnumber_second,f,true))
2646 {
2647 return qe_invalid;
2648 }
2649
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_igetl(&tempheader.compilerversionnumber_third,f,true))
2650 {
2651 return qe_invalid;
2652 }
2653
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f,true))
2654 {
2655 return qe_invalid;
2656 }
2657
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_igetw(&tempheader.developerid,f,true))
2658 {
2659 return qe_invalid;
2660 }
2661
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!pfread(tempheader.made_in_module_name,1024,f,true))
2662 {
2663 return qe_invalid;
2664 }
2665
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!pfread(tempheader.build_datestamp,256,f,true))
2666 {
2667 return qe_invalid;
2668 }
2669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!pfread(tempheader.build_timestamp,256,f,true))
2670 {
2671 return qe_invalid;
2672 }
2673 14 }
2674 else // <4
2675 {
2676 59 tempheader.new_version_id_main = 0;
2677 59 tempheader.new_version_id_second = 0;
2678 59 tempheader.new_version_id_third = 0;
2679 59 tempheader.new_version_id_fourth = 0;
2680 59 tempheader.new_version_id_alpha = 0;
2681 59 tempheader.new_version_id_beta = 0;
2682 59 tempheader.new_version_id_gamma = 0;
2683 59 tempheader.new_version_id_release = 0;
2684 59 tempheader.new_version_id_date_year = 0;
2685 59 tempheader.new_version_id_date_month = 0;
2686 59 tempheader.new_version_id_date_day = 0;
2687 59 tempheader.new_version_id_date_hour = 0;
2688 59 tempheader.new_version_id_date_minute = 0;
2689
2690 59 memset(tempheader.new_version_devsig, 0, 256);
2691 59 memset(tempheader.new_version_compilername, 0, 256);
2692 59 memset(tempheader.new_version_compilerversion, 0, 256);
2693 59 memset(tempheader.product_name, 0, 1024);
2694 59 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2695
2696 59 tempheader.compilerid = 0;
2697 59 tempheader.compilerversionnumber_first = 0;
2698 59 tempheader.compilerversionnumber_second = 0;
2699 59 tempheader.compilerversionnumber_third = 0;
2700 59 tempheader.compilerversionnumber_fourth = 0;
2701 59 tempheader.developerid = 0;
2702
2703 59 memset(tempheader.made_in_module_name, 0, 1024);
2704 59 memset(tempheader.build_datestamp, 0, 256);
2705 59 memset(tempheader.build_timestamp, 0, 256);
2706 }
2707
2708
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 59 times.
73 if ( version >= 5 )
2709 {
2710
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!pfread(tempheader.build_timezone,6,f,true))
2711 {
2712 return qe_invalid;
2713 }
2714 14 }
2715 else // < 5
2716 {
2717 59 memset(tempheader.build_timezone, 0, 6);
2718 }
2719
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 14 times.
73 if ( version >= 6 )
2720 {
2721 byte b;
2722
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_getc(&b,f,true))
2723 {
2724 return qe_invalid;
2725 }
2726 14 tempheader.external_zinfo = b?true:false;
2727 14 read_zinfo = true;
2728 14 }
2729
2730
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 59 times.
73 if(version >= 7)
2731 {
2732
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_getc(&(tempheader.new_version_is_nightly),f,true))
2733 {
2734 return qe_invalid;
2735 }
2736 14 }
2737 else
2738 {
2739 59 tempheader.new_version_is_nightly = false;
2740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(tempheader.zelda_version < 0x255)
2741 {
2742
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
59 switch(tempheader.zelda_version)
2743 {
2744 case 0x254:
2745 tempheader.new_version_id_main = 2;
2746 tempheader.new_version_id_second = 54;
2747 break;
2748 case 0x250:
2749
5/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 10 times.
✓ Branch 14 taken 8 times.
✗ Branch 15 not taken.
59 switch(tempheader.build)
2750 {
2751 case 19:
2752 tempheader.new_version_id_main = 2;
2753 tempheader.new_version_id_second = 50;
2754 tempheader.new_version_id_gamma = 1;
2755 break;
2756 case 20:
2757 tempheader.new_version_id_main = 2;
2758 tempheader.new_version_id_second = 50;
2759 tempheader.new_version_id_gamma = 2;
2760 break;
2761 case 21:
2762 tempheader.new_version_id_main = 2;
2763 tempheader.new_version_id_second = 50;
2764 tempheader.new_version_id_gamma = 3;
2765 break;
2766 case 22:
2767 tempheader.new_version_id_main = 2;
2768 tempheader.new_version_id_second = 50;
2769 tempheader.new_version_id_gamma = 4;
2770 break;
2771 case 23:
2772 tempheader.new_version_id_main = 2;
2773 tempheader.new_version_id_second = 50;
2774 tempheader.new_version_id_gamma = 5;
2775 break;
2776 case 24:
2777 13 tempheader.new_version_id_main = 2;
2778 13 tempheader.new_version_id_second = 50;
2779 13 tempheader.new_version_id_release = -1;
2780 13 break;
2781 case 25:
2782 tempheader.new_version_id_main = 2;
2783 tempheader.new_version_id_second = 50;
2784 tempheader.new_version_id_third = 1;
2785 tempheader.new_version_id_gamma = 1;
2786 break;
2787 case 26:
2788 tempheader.new_version_id_main = 2;
2789 tempheader.new_version_id_second = 50;
2790 tempheader.new_version_id_third = 1;
2791 tempheader.new_version_id_gamma = 2;
2792 break;
2793 case 27:
2794 tempheader.new_version_id_main = 2;
2795 tempheader.new_version_id_second = 50;
2796 tempheader.new_version_id_third = 1;
2797 tempheader.new_version_id_gamma = 3;
2798 break;
2799 case 28:
2800 5 tempheader.new_version_id_main = 2;
2801 5 tempheader.new_version_id_second = 50;
2802 5 tempheader.new_version_id_third = 1;
2803 5 tempheader.new_version_id_release = -1;
2804 5 break;
2805 case 29:
2806 23 tempheader.new_version_id_main = 2;
2807 23 tempheader.new_version_id_second = 50;
2808 23 tempheader.new_version_id_third = 2;
2809 23 tempheader.new_version_id_release = -1;
2810 23 break;
2811 case 30:
2812 tempheader.new_version_id_main = 2;
2813 tempheader.new_version_id_second = 50;
2814 tempheader.new_version_id_third = 3;
2815 tempheader.new_version_id_gamma = 1;
2816 break;
2817 case 31:
2818 10 tempheader.new_version_id_main = 2;
2819 10 tempheader.new_version_id_second = 53;
2820 10 tempheader.new_version_id_gamma = -1;
2821 10 break;
2822 case 32:
2823 8 tempheader.new_version_id_main = 2;
2824 8 tempheader.new_version_id_second = 53;
2825 8 tempheader.new_version_id_release = -1;
2826 8 break;
2827 case 33:
2828 tempheader.new_version_id_main = 2;
2829 tempheader.new_version_id_second = 53;
2830 tempheader.new_version_id_third = 1;
2831 break;
2832 }
2833 59 break;
2834
2835 case 0x211:
2836 tempheader.new_version_id_main = 2;
2837 tempheader.new_version_id_second = 11;
2838 tempheader.new_version_id_beta = tempheader.build;
2839 break;
2840 case 0x210:
2841 tempheader.new_version_id_main = 2;
2842 tempheader.new_version_id_second = 10;
2843 tempheader.new_version_id_beta = tempheader.build;
2844 break;
2845 }
2846 59 }
2847 }
2848
2/4
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73 times.
73 if(printmetadata || __isZQuest)
2849 {
2850 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2851 }
2852 }
2853
2854 //{ Version Warning
2855 73 int32_t vercmp = tempheader.compareVer();
2856 73 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2857 73 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2858
4/6
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 59 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
87 if(vercmp > 0 || (!vercmp &&
2859
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 (astatecmp > 0 || (!astatecmp &&
2860 14 avercmp > 0))))
2861 {
2862 bool r = true;
2863 if(loadquest_report)
2864 {
2865 enter_sys_pal();
2866 AlertDialog("Quest saved in newer version",
2867 "This quest was last saved in a newer version of ZQuest."
2868 " Attempting to load this quest may not work correctly; to"
2869 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2870 "\n\nWould you like to continue loading anyway? (Not recommended)",
2871 [&](bool ret,bool)
2872 {
2873 r = ret;
2874 }).show();
2875 exit_sys_pal();
2876 }
2877 if(!r)
2878 return qe_silenterr;
2879 }
2880
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 else if(tempheader.compareDate() > 0)
2881 {
2882 bool r = true;
2883 if(loadquest_report)
2884 {
2885 enter_sys_pal();
2886 AlertDialog("Quest saved in newer build",
2887 "This quest was last saved in a newer build of ZQuest, and may have"
2888 " issues loading in this build."
2889 "\n\nWould you like to continue loading anyway?",
2890 [&](bool ret,bool)
2891 {
2892 r = ret;
2893 }).show();
2894 exit_sys_pal();
2895 }
2896 if(!r)
2897 return qe_silenterr;
2898 }
2899 //}
2900
2901 73 read_ext_zinfo = tempheader.external_zinfo;
2902
2903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 if(keepdata==true)
2904 {
2905 73 memcpy(Header, &tempheader, sizeof(tempheader));
2906 73 map_count=temp_map_count;
2907 73 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2908 73 }
2909
2910 73 return 0;
2911 73 }
2912
2913 62 int32_t readrules(PACKFILE *f, zquestheader *Header, bool keepdata)
2914 {
2915 int32_t dummy;
2916 zquestheader tempheader;
2917 62 word s_version=0;
2918 62 dword compatrule_version=0;
2919
2920 62 memcpy(&tempheader, Header, sizeof(tempheader));
2921
2922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(tempheader.zelda_version >= 0x193)
2923 {
2924 //section version info
2925
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_version,f,true))
2926 {
2927 return qe_invalid;
2928 }
2929
2930 62 FFCore.quest_format[vRules] = s_version;
2931
2932
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&dummy,f,true))
2933 {
2934 return qe_invalid;
2935 }
2936
2937
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if(s_version > 16)
2938 {
2939
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&compatrule_version,f,true))
2940 {
2941 return qe_invalid;
2942 }
2943 3 }
2944 62 FFCore.quest_format[vCompatRule] = compatrule_version;
2945
2946 //section size
2947
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&dummy,f,true))
2948 {
2949 return qe_invalid;
2950 }
2951
2952
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if ( s_version < 15 )
2953 {
2954 //finally... section data
2955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(!pfread(quest_rules,QUESTRULES_SIZE,f,true))
2956 {
2957 return qe_invalid;
2958 }
2959 59 }
2960 else
2961 {
2962
2963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f,true))
2964 {
2965 return qe_invalid;
2966 }
2967
2968 }
2969 62 }
2970
2971 //al_trace("Rules version %d\n", s_version);
2972 //{ bunch of compat stuff
2973 62 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2974
2975
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version<2)
2976 {
2977 set_bit(quest_rules,14,0);
2978 set_bit(quest_rules,27,0);
2979 set_bit(quest_rules,28,0);
2980 set_bit(quest_rules,29,0);
2981 set_bit(quest_rules,30,0);
2982 set_bit(quest_rules,32,0);
2983 set_bit(quest_rules,36,0);
2984 set_bit(quest_rules,49,0);
2985 set_bit(quest_rules,50,0);
2986 set_bit(quest_rules,51,0);
2987 set_bit(quest_rules,68,0);
2988 set_bit(quest_rules,75,0);
2989 set_bit(quest_rules,76,0);
2990 set_bit(quest_rules,98,0);
2991 set_bit(quest_rules,110,0);
2992 set_bit(quest_rules,113,0);
2993 set_bit(quest_rules,116,0);
2994 set_bit(quest_rules,102,0);
2995 set_bit(quest_rules,132,0);
2996 }
2997
2998 //Now, do any updates...
2999
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3000 {
3001 set_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING,1);
3002 set_bit(quest_rules, qr_REPLACEOPENDOORS, 1);
3003 set_bit(quest_rules, qr_OLDLENSORDER, 1);
3004 set_bit(quest_rules, qr_NOFAIRYGUYFIRES, 1);
3005 set_bit(quest_rules, qr_TRIGGERSREPEAT, 1);
3006 }
3007
3008
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3009 {
3010 set_bit(quest_rules,qr_WALLFLIERS,1);
3011 }
3012
3013
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3014 {
3015 set_bit(quest_rules,qr_NOBOMBPALFLASH,1);
3016 }
3017
3018
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3019 {
3020 set_bit(quest_rules,qr_NOSCROLLCONTINUE,1);
3021 }
3022
3023
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(tempheader.zelda_version <= 0x210)
3024 {
3025 set_bit(quest_rules,qr_ARROWCLIP,1);
3026 }
3027
3028
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(tempheader.zelda_version == 0x210)
3029 {
3030 set_bit(quest_rules, qr_NOSCROLLCONTINUE, get_bit(quest_rules, qr_CMBCYCLELAYERS));
3031 set_bit(quest_rules, qr_CMBCYCLELAYERS, 0);
3032 set_bit(quest_rules, qr_CONT_SWORD_TRIGGERS, 1);
3033 }
3034
3035
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(tempheader.zelda_version <= 0x210)
3036 {
3037 set_bit(quest_rules,qr_OLDSTYLEWARP,1);
3038 set_bit(quest_rules,qr_210_WARPRETURN,1);
3039 }
3040
3041 //might not be correct
3042
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(tempheader.zelda_version < 0x210)
3043 {
3044 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3045 set_bit(quest_rules, qr_OLDHOOKSHOTGRAB,1);
3046 }
3047
3048
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(tempheader.zelda_version < 0x211)
3049 {
3050 set_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR,1);
3051 }
3052
3053
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3054 {
3055 set_bit(quest_rules, qr_192b163_WARP,1);
3056 }
3057
3058
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(tempheader.zelda_version == 0x210)
3059 {
3060 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_bit(quest_rules, qr_DMGCOMBOPRI));
3061 set_bit(quest_rules, qr_DMGCOMBOPRI, 0);
3062 }
3063
3064
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3065 {
3066 set_bit(quest_rules, qr_OLDPICKUP,1);
3067 }
3068
3069
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3070 {
3071 set_bit(quest_rules,qr_NOSOLIDDAMAGECOMBOS, 1);
3072 set_bit(quest_rules, qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3073 }
3074
3075
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3076 {
3077 set_bit(quest_rules,qr_HOOKSHOTDOWNBUG, 1);
3078 }
3079
3080
4/4
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 13 times.
62 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3081 {
3082 13 set_bit(quest_rules,qr_PEAHATCLOCKVULN, 1);
3083 13 }
3084
3085
4/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
62 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3086 {
3087 set_bit(quest_rules,qr_OLD_DOORREPAIR, 1);
3088 }
3089
3090
4/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
62 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3091 {
3092 set_bit(quest_rules,qr_OLD_SECRETMONEY, 1);
3093 }
3094
3095
5/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 46 times.
62 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3096 {
3097 13 set_bit(quest_rules,qr_OLD_POTION_OR_HC, 1);
3098 13 }
3099
3100
5/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 46 times.
62 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3101 {
3102 13 set_bit(quest_rules, qr_OFFSCREENWEAPONS, 1);
3103 13 }
3104
3105 //Bombchu fix.
3106
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(tempheader.zelda_version == 0x250)
3107 {
3108
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 13 times.
59 if ( tempheader.build == 24 ) //2.50.0
3109 {
3110 13 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3111 13 }
3112
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 5 times.
59 if ( tempheader.build == 28 ) //2.50.1
3113 {
3114 5 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3115 5 }
3116
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 23 times.
59 if ( tempheader.build == 29 ) //2.50.2
3117 {
3118 23 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3119 23 }
3120
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if ( tempheader.build == 30 ) //2.50.3RC1
3121 {
3122 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3123 }
3124 59 }
3125
3126
5/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 41 times.
62 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3127 {
3128 // qr_OFFSETEWPNCOLLISIONFIX
3129 // All 'official' quests need this disabled.
3130 // All 2.10 and lower quests need this enabled to preseve compatability.
3131 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3132
3133 //~Gleeok
3134 18 set_bit(quest_rules, qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3135
3136 // Broke in build 695
3137
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
18 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3138 18 set_bit(quest_rules, qr_BROKENSTATUES, 1);
3139 18 }
3140
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if (tempheader.zelda_version <= 0x190)
3141 {
3142 set_bit(quest_rules, qr_COPIED_SWIM_SPRITES, 1);
3143 }
3144
6/10
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
62 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3145 {
3146 59 set_bit(quest_rules, qr_OLD_SLASHNEXT_SECRETS, 1);
3147 59 }
3148
3149
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3150 {
3151 set_bit(quest_rules, qr_OLD_210_WATER, 1);
3152 }
3153
3154
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3155 {
3156 59 set_bit(quest_rules,qr_STEP_IS_FLOAT,0);
3157 59 }
3158
3159
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if ( tempheader.zelda_version < 0x250 )
3160 {
3161 set_bit(quest_rules, qr_8WAY_SHOT_SFX, 1);
3162 }
3163
3164
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version < 3)
3165 {
3166 set_bit(quest_rules, qr_HOLDNOSTOPMUSIC, 1);
3167 set_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC, 1);
3168 }
3169
3170
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version<4)
3171 {
3172 set_bit(quest_rules,10,0);
3173 }
3174
3175
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version<5)
3176 {
3177 set_bit(quest_rules,27,0);
3178 }
3179
3180
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version<6)
3181 {
3182 set_bit(quest_rules,46,0);
3183 }
3184
3185
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version<7) // January 2008
3186 {
3187 set_bit(quest_rules,qr_HEARTSREQUIREDFIX,0);
3188 set_bit(quest_rules,qr_PUSHBLOCKCSETFIX,1);
3189 }
3190
3191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(s_version<8)
3192 {
3193 set_bit(quest_rules, 12, 0);
3194 }
3195 else
3196 {
3197 62 set_bit(deprecated_rules, 12, 0);
3198 }
3199
3200
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version<9) // October 2008
3201 {
3202 set_bit(quest_rules,qr_NOROPE2FLASH_DEP,0);
3203 set_bit(quest_rules,qr_NOBUBBLEFLASH_DEP,0);
3204 set_bit(quest_rules,qr_GHINI2BLINK_DEP,0);
3205 set_bit(quest_rules,qr_PHANTOMGHINI2_DEP,0);
3206 }
3207
3208
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version<10) // December 2008
3209 {
3210 set_bit(quest_rules,qr_NOCLOCKS_DEP,0);
3211 set_bit(quest_rules, qr_ALLOW10RUPEEDROPS_DEP,0);
3212 }
3213
3214
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version<11) // April 2009
3215 {
3216 set_bit(quest_rules,qr_SLOWENEMYANIM_DEP,0);
3217 }
3218
3219
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version<12) // December 2009
3220 {
3221 set_bit(quest_rules,qr_BRKBLSHLDS_DEP,0);
3222 set_bit(quest_rules, qr_OLDTRIBBLES_DEP,0);
3223 }
3224
3225 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3226
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version < 13)
3227 {
3228 set_bit(quest_rules,qr_SHOPCHEAT, 1);
3229 }
3230
3231 // Not entirely sure this is the best place for this...
3232 //2.50.2 bitmap offset fix
3233 62 memset(extra_rules, 0, EXTRARULES_SIZE);
3234
5/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 41 times.
62 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3235 {
3236 18 set_bit(extra_rules, er_BITMAPOFFSET, 1);
3237 18 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 1);
3238 18 }
3239 //required because quest templates also used this bit, although
3240 //it never did anything, before. -Z
3241
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if ( tempheader.zelda_version == 0x250 )
3242 {
3243
5/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 26 times.
59 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3244 {
3245 33 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3246 33 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3247 33 }
3248 59 }
3249
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if ( tempheader.zelda_version == 0x254 )
3250 {
3251 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3252 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3253 }
3254
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
62 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3255 {
3256 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3257 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3258 }
3259 //optimise fast drawing for older versions.
3260
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3261 {
3262 59 set_bit(quest_rules, qr_OLDSPRITEDRAWS, 1);
3263 59 }
3264 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3265 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3266 //older quests can set the rule by hand. We need a new qst.dat again.
3267
4/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 59 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3268 {
3269 set_bit(quest_rules, qr_OLDEWPNPARENT, 1);
3270 }
3271
4/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 59 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3272 {
3273 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 1);
3274 }
3275
4/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 59 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3276 {
3277 set_bit(quest_rules, qr_OLDQUESTMISC, 1);
3278 }
3279
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if ( tempheader.zelda_version < 0x254 )
3280 {
3281 59 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 0);
3282 59 set_bit(quest_rules, qr_OLDEWPNPARENT, 0);
3283 59 set_bit(quest_rules, qr_OLDQUESTMISC, 0);
3284 59 }
3285
3286 //item scripts continue to run
3287
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3288 {
3289 59 set_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING, 0);
3290 59 set_bit(quest_rules, qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3291 59 set_bit(quest_rules, qr_FIXSCRIPTSDURINGSCROLLING, 0);
3292 59 set_bit(quest_rules, qr_SCRIPTDRAWSINWARPS, 0);
3293 59 set_bit(quest_rules, qr_DYINGENEMYESDONTHURTHERO, 0);
3294 59 set_bit(quest_rules, qr_OUTOFBOUNDSENEMIES, 0);
3295 59 set_bit(quest_rules, qr_SPRITEXY_IS_FLOAT, 0);
3296 59 }
3297
3298
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3299 {
3300 59 set_bit(quest_rules, qr_CLEARINITDONSCRIPTCHANGE, 1);
3301 59 }
3302
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3303 {
3304 59 set_bit(quest_rules, qr_TRACESCRIPTIDS, 0);
3305 59 set_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3306 59 set_bit(quest_rules, qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3307 59 set_bit(quest_rules,qr_PARSER_250DIVISION,1);
3308 59 set_bit(quest_rules,qr_PARSER_BOOL_TRUE_DECIMAL,1);
3309 59 set_bit(quest_rules,qr_PARSER_TRUE_INT_SIZE,0);
3310 59 set_bit(quest_rules,qr_PARSER_FORCE_INLINE,0);
3311 59 set_bit(quest_rules,qr_PARSER_BINARY_32BIT,0);
3312
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if ( get_bit(quest_rules, qr_SELECTAWPN) )
3313 {
3314 set_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3315 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3316 //Now they **do**, unless you disable that behaviour.
3317 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3318 //now enable the disable L/R item swap on load.
3319 }
3320
3321 59 }
3322
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3323 {
3324 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3325 59 set_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING, 1);
3326 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3327 //animations ending earlier than they should.
3328 59 set_bit(quest_rules, qr_BROKEN_ASKIP_Y_FRAMES, 1);
3329 //Enemies would ignore solidity on the top half of combos
3330 59 set_bit(quest_rules, qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3331 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3332 59 set_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3333 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3334 59 set_bit(quest_rules, qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3335 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3336 59 set_bit(quest_rules, qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3337 59 }
3338
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if ( tempheader.zelda_version < 0x255 )
3339 {
3340 59 set_bit(quest_rules, qr_NOFFCWAITDRAW, 1);
3341 59 set_bit(quest_rules, qr_NOITEMWAITDRAW, 1);
3342 59 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3343 59 set_bit(quest_rules, qr_OLD_INIT_SCRIPT_TIMING, 1);
3344 //set_bit(quest_rules, qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3345 59 }
3346
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3347 {
3348 59 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3349 59 }
3350
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3351 {
3352 59 set_bit(quest_rules, qr_OLD_PRINTF_ARGS, 1);
3353 59 }
3354
3355
3356
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3357 {
3358 59 set_bit(quest_rules, qr_BROKEN_RING_POWER, 1);
3359 59 }
3360
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3361 {
3362 59 set_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING, 1);
3363 59 }
3364
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3365 {
3366 59 set_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3367 59 }
3368
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3369 {
3370 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3371
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
3372 set_bit(quest_rules,qr_SET_YBUTTON_ITEMS,1);
3373 59 }
3374
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3375 {
3376 59 set_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0,1);
3377 59 }
3378
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3379 {
3380 59 set_bit(quest_rules,qr_OLD_CHEST_COLLISION,1);
3381 59 }
3382
3383
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if ( tempheader.zelda_version < 0x254 )
3384 {
3385 59 set_bit(quest_rules, qr_250WRITEEDEFSCRIPT, 1);
3386 59 }
3387 //Sideview spikes in 2.50.0
3388
5/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 46 times.
62 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3389 {
3390 13 set_bit(quest_rules, qr_OLDSIDEVIEWSPIKES, 1);
3391 13 }
3392 //more 2.50 fixes -Z
3393
5/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 41 times.
✓ Branch 5 taken 18 times.
62 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3394 {
3395 41 set_bit(quest_rules, qr_MELEEMAGICCOST, 0);
3396 41 set_bit(quest_rules, qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3397 41 set_bit(quest_rules, qr_OLDMIRRORCOMBOS, 1);
3398 41 set_bit(quest_rules, qr_BROKENBOOKCOST, 1);
3399 41 set_bit(quest_rules, qr_BROKENCHARINTDRAWING, 1);
3400
3401 41 }
3402
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3403 {
3404 //set_bit(quest_rules,qr_MELEEMAGICCOST, get_bit(extra_rules,er_MAGICCOSTSWORD));
3405 set_bit(quest_rules,qr_MELEEMAGICCOST, 1);
3406 }
3407
3408
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(tempheader.zelda_version < 0x193)
3409 {
3410 set_bit(quest_rules, qr_SHORTDGNWALK, 1);
3411 }
3412
3413
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(tempheader.zelda_version < 0x255)
3414 {
3415 59 set_bit(quest_rules, qr_OLDINFMAGIC, 1);
3416 59 }
3417
3418
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3419 {
3420 set_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR,1);
3421 }
3422
3423
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3424 {
3425 59 set_bit(quest_rules,qr_OLD_F6,1);
3426 59 }
3427
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3428 {
3429 59 set_bit(quest_rules,qr_NO_OVERWRITING_HOPPING,1);
3430 59 }
3431
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3432 {
3433 59 set_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3434 59 }
3435
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3436 {
3437 59 set_bit(quest_rules,qr_BROKEN_OVERWORLD_MINIMAP,1);
3438 59 }
3439 //}
3440
3441
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 1)
3442 {
3443 //Enemies->Secret only affects flag 16-31
3444 59 set_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31,1);
3445 59 }
3446
3447
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 2)
3448 {
3449 //Old CSet2 Handling
3450 59 set_bit(quest_rules,qr_OLDCS2,1);
3451 59 }
3452
3453
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 3)
3454 {
3455 //Hardcoded Shadow/Spawn/Death anim frames
3456 59 set_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS,1);
3457 59 }
3458
3459
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 4)
3460 {
3461 //Hardcoded Shadow/Spawn/Death anim frames
3462 59 set_bit(quest_rules,qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3463 59 }
3464
3465
3/4
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 59 times.
62 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250)
3466 {
3467 //Hardcoded Shadow/Spawn/Death anim frames
3468 59 set_bit(quest_rules,qr_NO_LANMOLA_RINGLEADER,1);
3469 59 }
3470
3471
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 6)
3472 {
3473 //Step->Secret (Temp) only affects flag 16-31
3474 59 set_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31,1);
3475 59 }
3476
3477
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 7)
3478 {
3479 //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3480 59 set_bit(quest_rules,qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3481 59 }
3482
3483
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 8)
3484 {
3485 //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3486 59 set_bit(quest_rules,qr_HARDCODED_LITEM_LTMS,1);
3487 59 }
3488
3489
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 9)
3490 {
3491 //Hardcoded BS Patras
3492 59 set_bit(quest_rules,qr_HARDCODED_BS_PATRA,1);
3493 //Hardcoded Patra Inner Eye offsets
3494 59 set_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3495 //Broken 'Big enemy' animation style
3496 59 set_bit(quest_rules,qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3497 //Broken Attribute 31/32
3498 59 set_bit(quest_rules,qr_BROKEN_ATTRIBUTE_31_32,1);
3499 59 }
3500
3501
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 10)
3502 {
3503 //Shared candle use limits
3504 59 set_bit(quest_rules,qr_CANDLES_SHARED_LIMIT,1);
3505 59 }
3506
3507
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 11)
3508 {
3509 //No cross-screen return points
3510 59 set_bit(quest_rules,qr_OLD_RESPAWN_POINTS,1);
3511 59 }
3512
3513
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 12)
3514 {
3515 //Old fire trail duration
3516 59 set_bit(quest_rules,qr_OLD_FLAMETRAIL_DURATION,1);
3517 //Old Intro String in Ganon Room Behavior
3518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(get_bit(quest_rules,qr_GANONINTRO)) set_bit(quest_rules,qr_GANONINTRO,0);
3519 59 else set_bit(quest_rules,qr_GANONINTRO,1);
3520 59 }
3521
3522
3/4
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
62 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255)
3523 {
3524 //ANone doesn't reset to originaltile
3525 set_bit(quest_rules,qr_ANONE_NOANIM,1);
3526 }
3527
3528
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 14)
3529 {
3530 //Old Bridge Combo Behavior
3531 59 set_bit(quest_rules,qr_OLD_BRIDGE_COMBOS,1);
3532 59 }
3533
3534
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 15)
3535 {
3536 //Broken Z3 Animation
3537 59 set_bit(quest_rules,qr_BROKEN_Z3_ANIMATION,1);
3538 59 }
3539
3540
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 16)
3541 {
3542 //Old Enemy Tile Behavior with Animation (None) Enemies
3543 59 set_bit(quest_rules,qr_OLD_TILE_INITIALIZATION,1);
3544 59 }
3545
3546
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 17)
3547 {
3548 //Old Quake/DrawYOffset behavior
3549 //set_bit(quest_rules,qr_OLD_DRAWOFFSET,1);
3550 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3551 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3552 59 }
3553
3554
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 18)
3555 {
3556 //Broken DrawScreen Derivative Functions
3557 59 set_bit(quest_rules,qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3558 //Scrolling Cancels Charge
3559 59 set_bit(quest_rules,qr_SCROLLING_KILLS_CHARGE,1);
3560 59 }
3561
3562
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 19)
3563 {
3564 //Broken Enemy Item Carrying with Large Enemies
3565 59 set_bit(quest_rules,qr_BROKEN_ITEM_CARRYING,1);
3566 59 }
3567
3568
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 20)
3569 {
3570 59 set_bit(quest_rules,qr_CUSTOMWEAPON_IGNORE_COST,1);
3571 59 }
3572
3573
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 21)
3574 {
3575 59 set_bit(quest_rules,qr_LEEVERS_DONT_OBEY_STUN,1);
3576 59 set_bit(quest_rules,qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3577 59 set_bit(quest_rules,qr_WIZZROBES_DONT_OBEY_STUN,1);
3578 59 set_bit(quest_rules,qr_OLD_BUG_NET,1);
3579 59 set_bit(quest_rules,qr_MANHANDLA_BLOCK_SFX,1);
3580 59 }
3581
3582
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 22)
3583 {
3584 59 set_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG,1);
3585 59 }
3586
3587
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 23)
3588 {
3589 59 set_bit(quest_rules,qr_OLD_HALF_MAGIC,1);
3590 59 }
3591
3592
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 24)
3593 {
3594 59 set_bit(quest_rules,qr_WARPS_RESTART_DMAPSCRIPT,1);
3595 59 set_bit(quest_rules,qr_DMAP_0_CONTINUE_BUG,1);
3596 59 }
3597
3598
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 25)
3599 {
3600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if (get_bit(quest_rules, qr_OLD_FAIRY_LIMIT)) set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,0);
3601 59 else set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,1);
3602 59 set_bit(quest_rules,qr_OLD_SCRIPTED_KNOCKBACK,1);
3603 59 }
3604
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 26)
3605 {
3606 59 set_bit(quest_rules,qr_OLD_KEESE_Z_AXIS,1);
3607 59 set_bit(quest_rules,qr_POLVIRE_NO_SHADOW,1);
3608 59 set_bit(quest_rules,qr_SUBSCR_OLD_SELECTOR,1);
3609 59 }
3610
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3611 {
3612
2/2
✓ Branch 0 taken 17759 times.
✓ Branch 1 taken 59 times.
17818 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3613 17759 set_bit(quest_rules,q,0);
3614
2/2
✓ Branch 0 taken 6608 times.
✓ Branch 1 taken 59 times.
6667 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3615 6608 set_bit(quest_rules,q,0);
3616 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3617 59 }
3618
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 28)
3619 {
3620 59 set_bit(quest_rules,qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3621 59 }
3622
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 29)
3623 {
3624 59 set_bit(quest_rules,qr_OLD_LOCKBLOCK_COLLISION,1);
3625 59 }
3626
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 30)
3627 {
3628 59 set_bit(quest_rules,qr_DECO_2_YOFFSET,1);
3629 59 set_bit(quest_rules,qr_SCREENSTATE_80s_BUG,1);
3630 59 }
3631
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 31)
3632 {
3633 59 set_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG,1);
3634 59 set_bit(quest_rules,qr_FFCPRELOAD_BUGGED_LOAD,1);
3635 59 }
3636
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 32)
3637 {
3638 59 set_bit(quest_rules,qr_BROKEN_GETPIXEL_VALUE,1);
3639 59 }
3640
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(compatrule_version < 33)
3641 {
3642 59 set_bit(quest_rules,qr_NO_LIFT_SPRITE,1);
3643 59 }
3644
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 61 times.
62 if(compatrule_version < 34)
3645 {
3646 61 set_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE,1);
3647 61 set_bit(quest_rules,qr_OLD_FFC_SPEED_CAP,1);
3648 61 set_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY,1);
3649 61 set_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING,1);
3650 61 }
3651
3652 //always set
3653 62 set_bit(quest_rules,qr_ANIMATECUSTOMWEAPONS,0);
3654
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if (s_version < 16) set_bit(quest_rules,qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata==true)
3656 {
3657 62 memcpy(Header, &tempheader, sizeof(tempheader));
3658 62 }
3659 62 return 0;
3660 62 }
3661
3662 511193 void init_msgstr(MsgStr *str)
3663 {
3664 511193 str->s = "";
3665 511193 str->s.shrink_to_fit();
3666 511193 str->nextstring=0;
3667 511193 str->tile=0;
3668 511193 str->cset=0;
3669 511193 str->trans=false;
3670 511193 str->font=font_zfont;
3671 511193 str->y=32;
3672 511193 str->sfx=18;
3673 511193 str->listpos=0;
3674 511193 str->x=24;
3675 511193 str->w=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3676 511193 str->h=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3677 511193 str->hspace=0;
3678 511193 str->vspace=0;
3679 511193 str->stringflags=0;
3680 511193 str->margins[up] = 8;
3681 511193 str->margins[down] = 0;
3682 511193 str->margins[left] = 8;
3683 511193 str->margins[right] = 0;
3684 511193 str->portrait_tile = 0;
3685 511193 str->portrait_cset = 0;
3686 511193 str->portrait_x = 0;
3687 511193 str->portrait_y = 0;
3688 511193 str->portrait_tw = 1;
3689 511193 str->portrait_th = 1;
3690 511193 str->shadow_type = 0;
3691 511193 str->shadow_color = 0;
3692 511193 str->drawlayer = 6;
3693 511193 }
3694
3695 62 void init_msgstrings(int32_t start, int32_t end)
3696 {
3697
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(end <= start || end-start > msg_strings_size)
3698 return;
3699
3700
2/2
✓ Branch 0 taken 507904 times.
✓ Branch 1 taken 62 times.
507966 for(int32_t i=start; i<end; i++)
3701 {
3702 507904 init_msgstr(&MsgStrings[i]);
3703 507904 MsgStrings[i].listpos=i;
3704 507904 }
3705
3706
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(start==0)
3707 {
3708 62 MsgStrings[0].s = "(None)";
3709 62 MsgStrings[0].listpos = 0;
3710 62 }
3711 62 }
3712
3713 62 int32_t readstrings(PACKFILE *f, zquestheader *Header, bool keepdata)
3714 {
3715 62 MsgStr tempMsgString;
3716
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 init_msgstr(&tempMsgString);
3717
3718 62 word temp_msg_count=0;
3719 word temp_expansion[16];
3720 62 memset(temp_expansion, 0, 16*sizeof(word));
3721 62 char buf[8193] = {0};
3722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(Header->zelda_version < 0x193)
3723 {
3724 byte tempbyte;
3725 int32_t strings_to_read=0;
3726 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3727 if((Header->zelda_version < 0x192)||
3728 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3729 {
3730 strings_to_read=128;
3731 temp_msg_count=Header->old_str_count;
3732
3733 // Some sort of string count corruption seems to be common in old quests
3734 if(temp_msg_count>128)
3735 {
3736 temp_msg_count=128;
3737 }
3738 }
3739 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3740 {
3741 strings_to_read=255;
3742 temp_msg_count=Header->old_str_count;
3743 }
3744 else
3745 {
3746 if(!p_igetw(&temp_msg_count,f,true))
3747 {
3748 return qe_invalid;
3749 }
3750
3751 strings_to_read=temp_msg_count;
3752
3753 if(temp_msg_count >= msg_strings_size)
3754 {
3755 Z_message("Reallocating string buffer...\n");
3756
3757 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3758 // return qe_nomem;
3759
3760 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3761 delete[] MsgStrings;
3762 MsgStrings = new MsgStr[MAXMSGS];
3763 msg_strings_size = MAXMSGS;
3764 for(auto q = 0; q < msg_strings_size; ++q)
3765 {
3766 MsgStrings[q].clear();
3767 }
3768 }
3769 }
3770
3771 //reset the message strings
3772 if(keepdata)
3773 {
3774 init_msgstrings(0,msg_strings_size);
3775 }
3776
3777 for(int32_t x=0; x<strings_to_read; x++)
3778 {
3779 init_msgstr(&tempMsgString);
3780
3781 if(!pfread(buf,73,f,true))
3782 {
3783 return qe_invalid;
3784 }
3785
3786 buf[74] = '\0';
3787 tempMsgString.s = buf;
3788
3789 if(!p_getc(&tempbyte,f,true))
3790 {
3791 return qe_invalid;
3792 }
3793
3794 if((Header->zelda_version < 0x192)||
3795 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3796 {
3797 tempMsgString.nextstring=tempbyte?x+1:0;
3798
3799 if(!p_getc(&tempbyte,f,true))
3800 {
3801 return qe_invalid;
3802 }
3803
3804 if(!p_getc(&tempbyte,f,true))
3805 {
3806 return qe_invalid;
3807 }
3808 }
3809 else
3810 {
3811 if(!p_igetw(&tempMsgString.nextstring,f,true))
3812 {
3813 return qe_invalid;
3814 }
3815
3816 if(!pfread(temp_expansion,32,f,true))
3817 {
3818 return qe_invalid;
3819 }
3820 }
3821
3822 if(keepdata==true)
3823 {
3824 MsgStrings[x] = tempMsgString;
3825 }
3826 }
3827 }
3828 else
3829 {
3830 int32_t dummy_int;
3831 word s_version;
3832 word s_cversion;
3833
3834 //section version info
3835
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&s_version,f,true))
3836 {
3837 return qe_invalid;
3838 }
3839
3840 62 FFCore.quest_format[vStrings] = s_version;
3841
3842
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&s_cversion,f,true))
3843 {
3844 return qe_invalid;
3845 }
3846
3847 //al_trace("Strings version %d\n", s_version);
3848 //section size
3849
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetl(&dummy_int,f,true))
3850 {
3851 return qe_invalid;
3852 }
3853
3854 //finally... section data
3855
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_msg_count,f,true))
3856 {
3857 return qe_invalid;
3858 }
3859
3860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(temp_msg_count >= msg_strings_size)
3861 {
3862 Z_message("Reallocating string buffer...\n");
3863
3864 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3865 // return qe_nomem;
3866 delete[] MsgStrings;
3867 MsgStrings = new MsgStr[MAXMSGS];
3868 msg_strings_size = MAXMSGS;
3869 for(auto q = 0; q < msg_strings_size; ++q)
3870 {
3871 MsgStrings[q].clear();
3872 }
3873 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3874 }
3875
3876 //reset the message strings
3877
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(keepdata)
3878 {
3879
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if(s_version < 7)
3880
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3881
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 init_msgstrings(0,msg_strings_size);
3882 62 }
3883
3884 62 int32_t string_length=(s_version<2)?73:145;
3885
3886
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 62 times.
3289 for(int32_t i=0; i<temp_msg_count; i++)
3887 {
3888
1/2
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
3227 init_msgstr(&tempMsgString);
3889
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3221 times.
3227 if(s_version > 8)
3890 {
3891
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetl(&string_length,f,true))
3892 {
3893 return qe_invalid;
3894 }
3895 6 }
3896
1/2
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
3227 if (string_length > 0)
3897 {
3898
2/4
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3227 times.
✗ Branch 3 not taken.
3227 if (!pfread(buf, string_length, f, true))
3899 {
3900 return qe_invalid;
3901 }
3902 3227 }
3903 else
3904 {
3905 buf[0] = 0;
3906 }
3907
3908
2/4
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3227 times.
✗ Branch 3 not taken.
3227 if(!p_igetw(&tempMsgString.nextstring,f,true))
3909 {
3910 return qe_invalid;
3911 }
3912
3913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3227 times.
3227 if(s_version<2)
3914 {
3915 buf[72] = '\0';
3916 tempMsgString.s = buf;
3917 }
3918 else
3919 {
3920 // June 2008: A bug corrupted the last 4 chars of a string.
3921 // Discard these.
3922
1/2
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
3227 if(s_version<3)
3923 {
3924 for(int32_t j=140; j<144; j++)
3925 {
3926 buf[j] = '\0';
3927 }
3928 }
3929
1/2
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
3227 if(string_length > 8192) string_length = 8192;
3930 3227 buf[string_length]='\0'; //Force-terminate
3931
1/2
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
3227 tempMsgString.s = buf;
3932
3933
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3221 times.
3227 if ( s_version >= 6 )
3934 {
3935
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetl(&tempMsgString.tile,f,true))
3936 {
3937 return qe_invalid;
3938 }
3939 6 }
3940 else
3941 {
3942
2/4
✓ Branch 0 taken 3221 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3221 times.
✗ Branch 3 not taken.
3221 if(!p_igetw(&tempMsgString.tile,f,true))
3943 {
3944 return qe_invalid;
3945 }
3946 }
3947
3948
2/4
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3227 times.
✗ Branch 3 not taken.
3227 if(!p_getc(&tempMsgString.cset,f,true))
3949 {
3950 return qe_invalid;
3951 }
3952
3953 byte dummy_char;
3954
3955
2/4
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3227 times.
✗ Branch 3 not taken.
3227 if(!p_getc(&dummy_char,f,true)) // trans is stored as a char...
3956 {
3957 return qe_invalid;
3958 }
3959
3960 3227 tempMsgString.trans=dummy_char!=0;
3961
3962
2/4
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3227 times.
✗ Branch 3 not taken.
3227 if(!p_getc(&tempMsgString.font,f,true))
3963 {
3964 return qe_invalid;
3965 }
3966
3967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3227 times.
3227 if(s_version < 5)
3968 {
3969 if(!p_getc(&tempMsgString.y,f,true))
3970 {
3971 return qe_invalid;
3972 }
3973 }
3974 else
3975 {
3976
2/4
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3227 times.
✗ Branch 3 not taken.
3227 if(!p_igetw(&tempMsgString.x,f,true))
3977 {
3978 return qe_invalid;
3979 }
3980
3981
2/4
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3227 times.
✗ Branch 3 not taken.
3227 if(!p_igetw(&tempMsgString.y,f,true))
3982 {
3983 return qe_invalid;
3984 }
3985
3986
2/4
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3227 times.
✗ Branch 3 not taken.
3227 if(!p_igetw(&tempMsgString.w,f,true))
3987 {
3988 return qe_invalid;
3989 }
3990
3991
2/4
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3227 times.
✗ Branch 3 not taken.
3227 if(!p_igetw(&tempMsgString.h,f,true))
3992 {
3993 return qe_invalid;
3994 }
3995
3996
2/4
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3227 times.
✗ Branch 3 not taken.
3227 if(!p_getc(&tempMsgString.hspace,f,true))
3997 {
3998 return qe_invalid;
3999 }
4000
4001
2/4
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3227 times.
✗ Branch 3 not taken.
3227 if(!p_getc(&tempMsgString.vspace,f,true))
4002 {
4003 return qe_invalid;
4004 }
4005
4006
2/4
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3227 times.
✗ Branch 3 not taken.
3227 if(!p_getc(&tempMsgString.stringflags,f,true))
4007 {
4008 return qe_invalid;
4009 }
4010 }
4011
4012
2/2
✓ Branch 0 taken 3221 times.
✓ Branch 1 taken 6 times.
3227 if(s_version >= 7)
4013 {
4014
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 24 times.
30 for(int32_t q = 0; q < 4; ++q)
4015 {
4016
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempMsgString.margins[q],f,true))
4017 {
4018 return qe_invalid;
4019 }
4020 24 }
4021
4022
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetl(&tempMsgString.portrait_tile,f,true))
4023 {
4024 return qe_invalid;
4025 }
4026
4027
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&tempMsgString.portrait_cset,f,true))
4028 {
4029 return qe_invalid;
4030 }
4031
4032
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&tempMsgString.portrait_x,f,true))
4033 {
4034 return qe_invalid;
4035 }
4036
4037
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&tempMsgString.portrait_y,f,true))
4038 {
4039 return qe_invalid;
4040 }
4041
4042
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&tempMsgString.portrait_tw,f,true))
4043 {
4044 return qe_invalid;
4045 }
4046
4047
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&tempMsgString.portrait_th,f,true))
4048 {
4049 return qe_invalid;
4050 }
4051 6 }
4052
4053
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3221 times.
3227 if(s_version >= 8)
4054 {
4055
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&tempMsgString.shadow_type,f,true))
4056 {
4057 return qe_invalid;
4058 }
4059
4060
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&tempMsgString.shadow_color,f,true))
4061 {
4062 return qe_invalid;
4063 }
4064 6 }
4065
4066
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3221 times.
3227 if(s_version >= 10)
4067 {
4068
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&tempMsgString.drawlayer,f,true))
4069 {
4070 return qe_invalid;
4071 }
4072 6 }
4073
4074
2/4
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3227 times.
✗ Branch 3 not taken.
3227 if(!p_getc(&tempMsgString.sfx,f,true))
4075 {
4076 return qe_invalid;
4077 }
4078
4079
1/2
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
3227 if(s_version>3)
4080 {
4081
2/4
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3227 times.
✗ Branch 3 not taken.
3227 if(!p_igetw(&tempMsgString.listpos,f,true))
4082 {
4083 return qe_invalid;
4084 }
4085 3227 }
4086 }
4087
4088
1/2
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
3227 if(keepdata==true)
4089 {
4090
1/2
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
3227 MsgStrings[i].copyAll(tempMsgString);
4091 3227 }
4092 3227 }
4093 }
4094
4095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata==true)
4096 {
4097 62 msg_count=temp_msg_count;
4098 62 }
4099
4100 62 return 0;
4101 62 }
4102
4103 62 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header, bool keepdata)
4104 {
4105
1/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 if((Header->zelda_version < 0x192)||
4106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4107 {
4108 return 0;
4109 }
4110
4111 62 word temp_door_combo_set_count=0;
4112 DoorComboSet tempDoorComboSet;
4113 word dummy_word;
4114 int32_t dummy_long;
4115 byte padding;
4116 62 int32_t s_version = 0;
4117
4118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata==true)
4119 {
4120
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4121 {
4122 15872 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4123 15872 }
4124 62 }
4125
4126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(Header->zelda_version > 0x192)
4127 {
4128 //section version info
4129
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_version,f,true))
4130 {
4131 return qe_invalid;
4132 }
4133
4134 62 FFCore.quest_format[vDoors] = s_version;
4135
4136 //al_trace("Door combo sets version %d\n", dummy_word);
4137
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&dummy_word,f,true))
4138 {
4139 return qe_invalid;
4140 }
4141
4142 //section size
4143
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&dummy_long,f,true))
4144 {
4145 return qe_invalid;
4146 }
4147 62 }
4148
4149 //finally... section data
4150
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&temp_door_combo_set_count,f,true))
4151 {
4152 return qe_invalid;
4153 }
4154
4155
2/2
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 62 times.
479 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4156 {
4157 417 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4158
4159 //name
4160
1/2
✓ Branch 0 taken 417 times.
✗ Branch 1 not taken.
417 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f,true))
4161 {
4162 return qe_invalid;
4163 }
4164
4165
1/2
✓ Branch 0 taken 417 times.
✗ Branch 1 not taken.
417 if(Header->zelda_version < 0x193)
4166 {
4167 if(!p_getc(&padding,f,true))
4168 {
4169 return qe_invalid;
4170 }
4171 }
4172
4173 //up door
4174
2/2
✓ Branch 0 taken 3753 times.
✓ Branch 1 taken 417 times.
4170 for(int32_t j=0; j<9; j++)
4175 {
4176
2/2
✓ Branch 0 taken 15012 times.
✓ Branch 1 taken 3753 times.
18765 for(int32_t k=0; k<4; k++)
4177 {
4178
1/2
✓ Branch 0 taken 15012 times.
✗ Branch 1 not taken.
15012 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f,true))
4179 {
4180 return qe_invalid;
4181 }
4182 15012 }
4183 3753 }
4184
4185
2/2
✓ Branch 0 taken 3753 times.
✓ Branch 1 taken 417 times.
4170 for(int32_t j=0; j<9; j++)
4186 {
4187
2/2
✓ Branch 0 taken 15012 times.
✓ Branch 1 taken 3753 times.
18765 for(int32_t k=0; k<4; k++)
4188 {
4189
1/2
✓ Branch 0 taken 15012 times.
✗ Branch 1 not taken.
15012 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f,true))
4190 {
4191 return qe_invalid;
4192 }
4193 15012 }
4194 3753 }
4195
4196 //down door
4197
2/2
✓ Branch 0 taken 3753 times.
✓ Branch 1 taken 417 times.
4170 for(int32_t j=0; j<9; j++)
4198 {
4199
2/2
✓ Branch 0 taken 15012 times.
✓ Branch 1 taken 3753 times.
18765 for(int32_t k=0; k<4; k++)
4200 {
4201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15012 times.
15012 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f,true))
4202 {
4203 return qe_invalid;
4204 }
4205 15012 }
4206 3753 }
4207
4208
2/2
✓ Branch 0 taken 3753 times.
✓ Branch 1 taken 417 times.
4170 for(int32_t j=0; j<9; j++)
4209 {
4210
2/2
✓ Branch 0 taken 15012 times.
✓ Branch 1 taken 3753 times.
18765 for(int32_t k=0; k<4; k++)
4211 {
4212
1/2
✓ Branch 0 taken 15012 times.
✗ Branch 1 not taken.
15012 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f,true))
4213 {
4214 return qe_invalid;
4215 }
4216 15012 }
4217 3753 }
4218
4219 //left door
4220
2/2
✓ Branch 0 taken 3753 times.
✓ Branch 1 taken 417 times.
4170 for(int32_t j=0; j<9; j++)
4221 {
4222
2/2
✓ Branch 0 taken 22518 times.
✓ Branch 1 taken 3753 times.
26271 for(int32_t k=0; k<6; k++)
4223 {
4224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22518 times.
22518 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f,true))
4225 {
4226 return qe_invalid;
4227 }
4228 22518 }
4229 3753 }
4230
4231
2/2
✓ Branch 0 taken 3753 times.
✓ Branch 1 taken 417 times.
4170 for(int32_t j=0; j<9; j++)
4232 {
4233
2/2
✓ Branch 0 taken 22518 times.
✓ Branch 1 taken 3753 times.
26271 for(int32_t k=0; k<6; k++)
4234 {
4235
1/2
✓ Branch 0 taken 22518 times.
✗ Branch 1 not taken.
22518 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f,true))
4236 {
4237 return qe_invalid;
4238 }
4239 22518 }
4240 3753 }
4241
4242 //right door
4243
2/2
✓ Branch 0 taken 3753 times.
✓ Branch 1 taken 417 times.
4170 for(int32_t j=0; j<9; j++)
4244 {
4245
2/2
✓ Branch 0 taken 22518 times.
✓ Branch 1 taken 3753 times.
26271 for(int32_t k=0; k<6; k++)
4246 {
4247
1/2
✓ Branch 0 taken 22518 times.
✗ Branch 1 not taken.
22518 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f,true))
4248 {
4249 return qe_invalid;
4250 }
4251 22518 }
4252 3753 }
4253
4254
2/2
✓ Branch 0 taken 3753 times.
✓ Branch 1 taken 417 times.
4170 for(int32_t j=0; j<9; j++)
4255 {
4256
2/2
✓ Branch 0 taken 22518 times.
✓ Branch 1 taken 3753 times.
26271 for(int32_t k=0; k<6; k++)
4257 {
4258
1/2
✓ Branch 0 taken 22518 times.
✗ Branch 1 not taken.
22518 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f,true))
4259 {
4260 return qe_invalid;
4261 }
4262 22518 }
4263 3753 }
4264
4265 //up bomb rubble
4266
2/2
✓ Branch 0 taken 834 times.
✓ Branch 1 taken 417 times.
1251 for(int32_t j=0; j<2; j++)
4267 {
4268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 834 times.
834 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f,true))
4269 {
4270 return qe_invalid;
4271 }
4272 834 }
4273
4274
2/2
✓ Branch 0 taken 834 times.
✓ Branch 1 taken 417 times.
1251 for(int32_t j=0; j<2; j++)
4275 {
4276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 834 times.
834 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f,true))
4277 {
4278 return qe_invalid;
4279 }
4280 834 }
4281
4282 //down bomb rubble
4283
2/2
✓ Branch 0 taken 834 times.
✓ Branch 1 taken 417 times.
1251 for(int32_t j=0; j<2; j++)
4284 {
4285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 834 times.
834 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f,true))
4286 {
4287 return qe_invalid;
4288 }
4289 834 }
4290
4291
2/2
✓ Branch 0 taken 834 times.
✓ Branch 1 taken 417 times.
1251 for(int32_t j=0; j<2; j++)
4292 {
4293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 834 times.
834 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f,true))
4294 {
4295 return qe_invalid;
4296 }
4297 834 }
4298
4299 //left bomb rubble
4300
2/2
✓ Branch 0 taken 1251 times.
✓ Branch 1 taken 417 times.
1668 for(int32_t j=0; j<3; j++)
4301 {
4302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1251 times.
1251 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f,true))
4303 {
4304 return qe_invalid;
4305 }
4306 1251 }
4307
4308
2/2
✓ Branch 0 taken 1251 times.
✓ Branch 1 taken 417 times.
1668 for(int32_t j=0; j<3; j++)
4309 {
4310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1251 times.
1251 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f,true))
4311 {
4312 return qe_invalid;
4313 }
4314 1251 }
4315
4316
1/2
✓ Branch 0 taken 417 times.
✗ Branch 1 not taken.
417 if(Header->zelda_version < 0x193)
4317 {
4318 if(!p_getc(&padding,f,true))
4319 {
4320 return qe_invalid;
4321 }
4322
4323 }
4324
4325 //right bomb rubble
4326
2/2
✓ Branch 0 taken 1251 times.
✓ Branch 1 taken 417 times.
1668 for(int32_t j=0; j<3; j++)
4327 {
4328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1251 times.
1251 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f,true))
4329 {
4330 return qe_invalid;
4331 }
4332 1251 }
4333
4334
2/2
✓ Branch 0 taken 1251 times.
✓ Branch 1 taken 417 times.
1668 for(int32_t j=0; j<3; j++)
4335 {
4336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1251 times.
1251 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f,true))
4337 {
4338 return qe_invalid;
4339 }
4340 1251 }
4341
4342
1/2
✓ Branch 0 taken 417 times.
✗ Branch 1 not taken.
417 if(Header->zelda_version < 0x193)
4343 {
4344 if(!p_getc(&padding,f,true))
4345 {
4346 return qe_invalid;
4347 }
4348 }
4349
4350 //walkthrough stuff
4351
2/2
✓ Branch 0 taken 1668 times.
✓ Branch 1 taken 417 times.
2085 for(int32_t j=0; j<4; j++)
4352 {
4353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1668 times.
1668 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f,true))
4354 {
4355 return qe_invalid;
4356 }
4357 1668 }
4358
4359
2/2
✓ Branch 0 taken 1668 times.
✓ Branch 1 taken 417 times.
2085 for(int32_t j=0; j<4; j++)
4360 {
4361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1668 times.
1668 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f,true))
4362 {
4363 return qe_invalid;
4364 }
4365 1668 }
4366
4367 //flags
4368
2/2
✓ Branch 0 taken 834 times.
✓ Branch 1 taken 417 times.
1251 for(int32_t j=0; j<2; j++)
4369 {
4370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 834 times.
834 if(!p_getc(&tempDoorComboSet.flags[j],f,true))
4371 {
4372 return qe_invalid;
4373 }
4374 834 }
4375
4376
1/2
✓ Branch 0 taken 417 times.
✗ Branch 1 not taken.
417 if(Header->zelda_version < 0x193)
4377 {
4378 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f,true))
4379 {
4380 return qe_invalid;
4381 }
4382 }
4383
4384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417 times.
417 if(keepdata==true)
4385 {
4386 417 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4387 417 }
4388 417 }
4389
4390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata==true)
4391 {
4392 62 door_combo_set_count=temp_door_combo_set_count;
4393 62 }
4394
4395 62 return 0;
4396 62 }
4397
4398 int32_t count_dmaps()
4399 {
4400 int32_t i=MAXDMAPS-1;
4401 bool found=false;
4402
4403 while(i>=0 && !found)
4404 {
4405 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4406 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4407 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4408 found=true;
4409
4410 for(int32_t j=0; j<8; j++)
4411 {
4412 if(DMaps[i].grid[j]!=0)
4413
4414 found=true;
4415 }
4416
4417 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4418 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4419 found=true;
4420
4421 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4422 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4423 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4424 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4425 found=true;
4426
4427 if(!found)
4428 {
4429 i--;
4430 }
4431 }
4432
4433 return i+1;
4434 }
4435
4436
4437 int32_t count_shops(miscQdata *Misc)
4438 {
4439 int32_t i=255,j;
4440 bool found=false;
4441
4442 while(i>=0 && !found)
4443 {
4444 j=2;
4445
4446 while(j>=0 && !found)
4447 {
4448 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4449 {
4450 found=true;
4451 }
4452 else
4453 {
4454 j--;
4455 }
4456 }
4457
4458 if(Misc->shop[i].name[0]!=0)
4459 {
4460 found=true;
4461 }
4462
4463 if(!found)
4464 {
4465 i--;
4466 }
4467 }
4468
4469 return i+1;
4470 }
4471
4472 int32_t count_infos(miscQdata *Misc)
4473 {
4474 int32_t i=255,j;
4475 bool found=false;
4476
4477 while(i>=0 && !found)
4478 {
4479 j=2;
4480
4481 while(j>=0 && !found)
4482 {
4483 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4484 {
4485 found=true;
4486 }
4487 else
4488 {
4489 j--;
4490 }
4491 }
4492
4493 if(Misc->info[i].name[0]!=0)
4494 {
4495 found=true;
4496 }
4497
4498 if(!found)
4499 {
4500 i--;
4501 }
4502 }
4503
4504 return i+1;
4505 }
4506
4507 int32_t count_warprings(miscQdata *Misc)
4508 {
4509 int32_t i=15,j;
4510 bool found=false;
4511
4512 while(i>=0 && !found)
4513 {
4514 j=7;
4515
4516 while(j>=0 && !found)
4517 {
4518 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4519 {
4520 found=true;
4521 }
4522 else
4523 {
4524 j--;
4525 }
4526 }
4527
4528 if(!found)
4529 {
4530 i--;
4531 }
4532 }
4533
4534 return i+1;
4535 }
4536
4537 int32_t count_palcycles(miscQdata *Misc)
4538 {
4539 int32_t i=255,j;
4540 bool found=false;
4541
4542 while(i>=0 && !found)
4543 {
4544 j=2;
4545
4546 while(j>=0 && !found)
4547 {
4548 if(Misc->cycles[i][j].count!=0)
4549 {
4550 found=true;
4551 }
4552 else
4553 {
4554 j--;
4555 }
4556 }
4557
4558 if(!found)
4559 {
4560 i--;
4561 }
4562 }
4563
4564 return i+1;
4565 }
4566
4567 99750 void clear_screen(mapscr *temp_scr)
4568 {
4569 99750 temp_scr->zero_memory();
4570 99750 }
4571
4572 62 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps, bool keepdata)
4573 {
4574 62 word dmapstoread=0;
4575 dmap tempDMap;
4576
4577 int32_t dummy;
4578 62 word s_version=0, s_cversion=0;
4579 byte padding;
4580
4581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata==true)
4582 {
4583
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 62 times.
31806 for(int32_t i=0; i<max_dmaps; i++)
4584 {
4585 31744 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4586 31744 sprintf(DMaps[start_dmap+i].title," ");
4587 31744 sprintf(DMaps[start_dmap+i].intro," ");
4588 31744 DMaps[start_dmap+i].type |= dmCAVE;
4589 31744 }
4590 62 }
4591
4592
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!Header || Header->zelda_version > 0x192)
4593 {
4594 //section version info
4595
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_version,f,true))
4596 {
4597 return qe_invalid;
4598 }
4599
4600 62 FFCore.quest_format[vDMaps] = s_version;
4601
4602 //al_trace("DMaps version %d\n", s_version);
4603
4604
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_cversion,f,true))
4605 {
4606 return qe_invalid;
4607 }
4608
4609 //section size
4610
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&dummy,f,true))
4611 {
4612 return qe_invalid;
4613 }
4614
4615 //finally... section data
4616
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&dmapstoread,f,true))
4617 {
4618 return qe_invalid;
4619 }
4620 62 }
4621 else
4622 {
4623 if((Header->zelda_version < 0x192)||
4624 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4625 {
4626 dmapstoread=32;
4627 }
4628 else if(s_version <= 4)
4629 {
4630 dmapstoread=OLDMAXDMAPS;
4631 }
4632 else
4633 {
4634 dmapstoread=MAXDMAPS;
4635 }
4636 }
4637
4638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 dmapstoread=zc_min(dmapstoread, max_dmaps);
4639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4640
4641
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 62 times.
31806 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4642 {
4643 31744 memset(&tempDMap,0,sizeof(dmap));
4644 31744 sprintf(tempDMap.title," ");
4645 31744 sprintf(tempDMap.intro," ");
4646
4647
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&tempDMap.map,f,keepdata))
4648 {
4649 return qe_invalid;
4650 }
4651
4652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31744 times.
31744 if(s_version <= 4)
4653 {
4654 byte tempbyte;
4655
4656 if(!p_getc(&tempbyte,f,keepdata))
4657 {
4658 return qe_invalid;
4659 }
4660
4661 tempDMap.level=(word)tempbyte;
4662 }
4663 else
4664 {
4665
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&tempDMap.level,f,keepdata))
4666 {
4667 return qe_invalid;
4668 }
4669 }
4670
4671
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&tempDMap.xoff,f,keepdata))
4672 {
4673 return qe_invalid;
4674 }
4675
4676
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&tempDMap.compass,f,keepdata))
4677 {
4678 return qe_invalid;
4679 }
4680
4681
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(s_version > 8) // February 2009
4682 {
4683
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&tempDMap.color,f,true))
4684 {
4685 return qe_invalid;
4686 }
4687 31744 }
4688 else
4689 {
4690 byte tempbyte;
4691
4692 if(!p_getc(&tempbyte,f,true))
4693 {
4694 return qe_invalid;
4695 }
4696
4697 tempDMap.color = (word)tempbyte;
4698 }
4699
4700
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&tempDMap.midi,f,keepdata))
4701 {
4702 return qe_invalid;
4703 }
4704
4705
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&tempDMap.cont,f,keepdata))
4706 {
4707 return qe_invalid;
4708 }
4709
4710
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&tempDMap.type,f,keepdata))
4711 {
4712 return qe_invalid;
4713 }
4714
4715
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 31565 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
31923 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4716
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4717 179 tempDMap.xoff = 0;
4718
4719
2/2
✓ Branch 0 taken 253952 times.
✓ Branch 1 taken 31744 times.
285696 for(int32_t j=0; j<8; j++)
4720 {
4721
1/2
✓ Branch 0 taken 253952 times.
✗ Branch 1 not taken.
253952 if(!p_getc(&tempDMap.grid[j],f,keepdata))
4722 {
4723 return qe_invalid;
4724 }
4725 253952 }
4726
4727
3/8
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31744 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 31744 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
31744 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4728 {
4729 if(tempDMap.level>0&&tempDMap.level<10)
4730 {
4731 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4732 }
4733
4734 if(i==0 && Header->zelda_version <= 0x190)
4735 {
4736 tempDMap.cont-=tempDMap.xoff;
4737 tempDMap.compass-=tempDMap.xoff;
4738 }
4739
4740 //forgotten -DD
4741 if(tempDMap.level==0)
4742 {
4743 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4744 }
4745 }
4746 else
4747 {
4748
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f,true))
4749 {
4750 return qe_invalid;
4751 }
4752
4753
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f,true))
4754 {
4755 return qe_invalid;
4756 }
4757
4758
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f,true))
4759 {
4760 return qe_invalid;
4761 }
4762
4763
3/8
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31744 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 31744 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
31744 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4764 {
4765 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4766 if(keepdata==true)
4767 {
4768 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4769 }
4770
4771 continue;
4772 }
4773
4774
2/4
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31744 times.
✗ Branch 3 not taken.
31744 if(Header && (Header->zelda_version < 0x193))
4775 {
4776 if(!p_getc(&padding,f,keepdata))
4777 {
4778 return qe_invalid;
4779 }
4780 }
4781
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if ( s_version >= 11 )
4782 {
4783
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&tempDMap.minimap_1_tile,f,keepdata))
4784 {
4785 return qe_invalid;
4786 }
4787 1536 }
4788 else
4789 {
4790
1/2
✓ Branch 0 taken 30208 times.
✗ Branch 1 not taken.
30208 if(!p_igetw(&tempDMap.minimap_1_tile,f,keepdata))
4791 {
4792 return qe_invalid;
4793 }
4794 }
4795
4796
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&tempDMap.minimap_1_cset,f,keepdata))
4797 {
4798 return qe_invalid;
4799 }
4800
4801
2/4
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31744 times.
✗ Branch 3 not taken.
31744 if(Header && (Header->zelda_version < 0x193))
4802 {
4803 if(!p_getc(&padding,f,keepdata))
4804 {
4805 return qe_invalid;
4806 }
4807 }
4808
4809
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if ( s_version >= 11 )
4810 {
4811
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&tempDMap.minimap_2_tile,f,keepdata))
4812 {
4813 return qe_invalid;
4814 }
4815 1536 }
4816 else
4817 {
4818
1/2
✓ Branch 0 taken 30208 times.
✗ Branch 1 not taken.
30208 if(!p_igetw(&tempDMap.minimap_2_tile,f,keepdata))
4819 {
4820 return qe_invalid;
4821 }
4822 }
4823
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&tempDMap.minimap_2_cset,f,keepdata))
4824 {
4825 return qe_invalid;
4826 }
4827
4828
2/4
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31744 times.
✗ Branch 3 not taken.
31744 if(Header && (Header->zelda_version < 0x193))
4829 {
4830 if(!p_getc(&padding,f,keepdata))
4831 {
4832 return qe_invalid;
4833 }
4834 }
4835
4836
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if ( s_version >= 11 )
4837 {
4838
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&tempDMap.largemap_1_tile,f,keepdata))
4839 {
4840 return qe_invalid;
4841 }
4842 1536 }
4843 else
4844 {
4845
1/2
✓ Branch 0 taken 30208 times.
✗ Branch 1 not taken.
30208 if(!p_igetw(&tempDMap.largemap_1_tile,f,keepdata))
4846 {
4847 return qe_invalid;
4848 }
4849 }
4850
4851
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&tempDMap.largemap_1_cset,f,keepdata))
4852 {
4853 return qe_invalid;
4854 }
4855
4856
2/4
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31744 times.
✗ Branch 3 not taken.
31744 if(Header && (Header->zelda_version < 0x193))
4857 {
4858
4859 if(!p_getc(&padding,f,keepdata))
4860 {
4861 return qe_invalid;
4862 }
4863 }
4864
4865
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if ( s_version >= 11 )
4866 {
4867
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&tempDMap.largemap_2_tile,f,keepdata))
4868 {
4869 return qe_invalid;
4870 }
4871 1536 }
4872 else
4873 {
4874
1/2
✓ Branch 0 taken 30208 times.
✗ Branch 1 not taken.
30208 if(!p_igetw(&tempDMap.largemap_2_tile,f,keepdata))
4875 {
4876 return qe_invalid;
4877 }
4878 }
4879
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&tempDMap.largemap_2_cset,f,keepdata))
4880 {
4881 return qe_invalid;
4882 }
4883
4884
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f,true))
4885 {
4886 return qe_invalid;
4887 }
4888 }
4889
4890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31744 times.
31744 if(s_version>1)
4891 {
4892
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&tempDMap.tmusictrack,f,keepdata))
4893 {
4894 return qe_invalid;
4895 }
4896
4897
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&tempDMap.active_subscreen,f,keepdata))
4898 {
4899 return qe_invalid;
4900 }
4901
4902
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&tempDMap.passive_subscreen,f,keepdata))
4903 {
4904 return qe_invalid;
4905 }
4906 31744 }
4907
4908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31744 times.
31744 if(s_version>2)
4909 {
4910 byte di[32];
4911
4912
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!pfread(&di, 32, f, true)) return qe_invalid;
4913
4914
2/2
✓ Branch 0 taken 8126464 times.
✓ Branch 1 taken 31744 times.
8158208 for(int32_t j=0; j<MAXITEMS; j++)
4915 {
4916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8126464 times.
8126464 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4917 8126464 else tempDMap.disableditems[j]=0;
4918 8126464 }
4919 31744 }
4920
4921
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(s_version >= 6)
4922 {
4923
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetl(&tempDMap.flags,f,keepdata))
4924 {
4925 return qe_invalid;
4926 }
4927 31744 }
4928 else if(s_version>3)
4929 {
4930 char temp;
4931
4932 if(!p_getc(&temp,f,keepdata))
4933 {
4934 return qe_invalid;
4935 }
4936
4937 tempDMap.flags = temp;
4938 }
4939 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4940 {
4941 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4942 }
4943 else
4944 tempDMap.flags=0;
4945
4946
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(s_version<7)
4947 {
4948 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4949 tempDMap.flags|= dmfVIEWMAP;
4950 }
4951
4952
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(s_version<8)
4953 {
4954 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4955 {
4956 tempDMap.type &= ~dmDNGN;
4957 tempDMap.type |= dmCAVE;
4958 }
4959 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4960 {
4961 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4962 }
4963 }
4964
4965
3/8
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 31744 times.
✗ Branch 7 not taken.
31744 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4966 31744 && (Header->zelda_version < 0x193))
4967 {
4968 if(!p_getc(&padding,f,keepdata))
4969 {
4970 return qe_invalid;
4971 }
4972 }
4973
4974
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 1536 times.
31744 if(s_version >= 10)
4975 {
4976
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_getc(&tempDMap.sideview,f,keepdata))
4977 {
4978 return qe_invalid;
4979 }
4980 1536 }
4981
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if(s_version < 10) tempDMap.sideview = 0;
4982
4983 //Dmap Scripts
4984
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 1536 times.
31744 if(s_version >= 12)
4985 {
4986
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&tempDMap.script,f,keepdata))
4987 {
4988 return qe_invalid;
4989 }
4990
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for ( int32_t q = 0; q < 8; q++ )
4991 {
4992
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&tempDMap.initD[q],f,keepdata))
4993 {
4994 return qe_invalid;
4995 }
4996 12288 }
4997 1536 }
4998
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if ( s_version < 12 )
4999 {
5000 30208 tempDMap.script = 0;
5001
2/2
✓ Branch 0 taken 241664 times.
✓ Branch 1 taken 30208 times.
271872 for ( int32_t q = 0; q < 8; q++ )
5002 {
5003 241664 tempDMap.initD[q] = 0;
5004 241664 }
5005 30208 }
5006
5007
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 1536 times.
31744 if(s_version >= 13)
5008 {
5009
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for ( int32_t q = 0; q < 8; q++ )
5010 {
5011
2/2
✓ Branch 0 taken 798720 times.
✓ Branch 1 taken 12288 times.
811008 for ( int32_t w = 0; w < 65; w++ )
5012 {
5013
1/2
✓ Branch 0 taken 798720 times.
✗ Branch 1 not taken.
798720 if(!p_getc(&tempDMap.initD_label[q][w],f,keepdata))
5014 {
5015 return qe_invalid;
5016 }
5017 798720 }
5018 12288 }
5019 1536 }
5020
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if ( s_version < 13 )
5021 {
5022 30208 tempDMap.script = 0;
5023
2/2
✓ Branch 0 taken 241664 times.
✓ Branch 1 taken 30208 times.
271872 for ( int32_t q = 0; q < 8; q++ )
5024 {
5025
2/2
✓ Branch 0 taken 15708160 times.
✓ Branch 1 taken 241664 times.
15949824 for ( int32_t w = 0; w < 65; w++ )
5026 15708160 tempDMap.initD_label[q][w] = 0;
5027 241664 }
5028 30208 }
5029
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if(s_version >= 14)
5030 {
5031
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&tempDMap.active_sub_script,f,keepdata))
5032 {
5033 return qe_invalid;
5034 }
5035
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&tempDMap.passive_sub_script,f,keepdata))
5036 {
5037 return qe_invalid;
5038 }
5039
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for ( int32_t q = 0; q < 8; ++q )
5040 {
5041
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&tempDMap.sub_initD[q],f,keepdata))
5042 {
5043 return qe_invalid;
5044 }
5045 12288 }
5046
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for(int32_t q = 0; q < 8; ++q)
5047 {
5048
2/2
✓ Branch 0 taken 798720 times.
✓ Branch 1 taken 12288 times.
811008 for ( int32_t w = 0; w < 65; ++w )
5049 {
5050
1/2
✓ Branch 0 taken 798720 times.
✗ Branch 1 not taken.
798720 if(!p_getc(&tempDMap.sub_initD_label[q][w],f,keepdata))
5051 {
5052 return qe_invalid;
5053 }
5054 798720 }
5055 12288 }
5056 1536 }
5057 else
5058 {
5059 30208 tempDMap.active_sub_script = 0;
5060 30208 tempDMap.passive_sub_script = 0;
5061
2/2
✓ Branch 0 taken 241664 times.
✓ Branch 1 taken 30208 times.
271872 for(int32_t q = 0; q < 8; ++q)
5062 {
5063 241664 tempDMap.sub_initD[q] = 0;
5064
2/2
✓ Branch 0 taken 15708160 times.
✓ Branch 1 taken 241664 times.
15949824 for(int32_t w = 0; w < 65; ++w)
5065 15708160 tempDMap.sub_initD_label[q][w] = 0;
5066 241664 }
5067 }
5068
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if(s_version >= 15)
5069 {
5070
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&tempDMap.onmap_script,f,keepdata))
5071 {
5072 return qe_invalid;
5073 }
5074
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for ( int32_t q = 0; q < 8; ++q )
5075 {
5076
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&tempDMap.onmap_initD[q],f,keepdata))
5077 {
5078 return qe_invalid;
5079 }
5080 12288 }
5081
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for(int32_t q = 0; q < 8; ++q)
5082 {
5083
2/2
✓ Branch 0 taken 798720 times.
✓ Branch 1 taken 12288 times.
811008 for ( int32_t w = 0; w < 65; ++w )
5084 {
5085
1/2
✓ Branch 0 taken 798720 times.
✗ Branch 1 not taken.
798720 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f,keepdata))
5086 {
5087 return qe_invalid;
5088 }
5089 798720 }
5090 12288 }
5091 1536 }
5092 else
5093 {
5094 30208 tempDMap.onmap_script = 0;
5095
2/2
✓ Branch 0 taken 241664 times.
✓ Branch 1 taken 30208 times.
271872 for(int32_t q = 0; q < 8; ++q)
5096 {
5097 241664 tempDMap.onmap_initD[q] = 0;
5098
2/2
✓ Branch 0 taken 15708160 times.
✓ Branch 1 taken 241664 times.
15949824 for(int32_t w = 0; w < 65; ++w)
5099 {
5100 15708160 tempDMap.onmap_initD_label[q][w] = 0;
5101 15708160 }
5102 241664 }
5103 }
5104
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if(s_version >= 16)
5105 {
5106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_igetw(&tempDMap.mirrorDMap,f,keepdata))
5107 {
5108 return qe_invalid;
5109 }
5110 1536 }
5111 else
5112 {
5113 30208 tempDMap.mirrorDMap = -1;
5114 }
5115
5116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31744 times.
31744 if(keepdata==true)
5117 {
5118 31744 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5119 31744 }
5120 31744 }
5121
5122 62 return 0;
5123 62 }
5124
5125 62 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5126 {
5127 //these are here to bypass compiler warnings about unused arguments
5128 62 Header=Header;
5129
5130 miscQdata temp_misc;
5131 62 word s_version=0, s_cversion=0;
5132 62 int32_t tempsize=0;
5133 word dummyw;
5134
5135 62 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5136
5137 //section version info
5138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(!p_igetw(&s_version,f,true))
5139 {
5140 return qe_invalid;
5141 }
5142
5143 62 FFCore.quest_format[vColours] = s_version;
5144
5145 62 al_trace("Misc Colours section version: %d\n", s_version);
5146
5147 //al_trace("Misc. colors version %d\n", s_version);
5148
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_cversion,f,true))
5149 {
5150 return qe_invalid;
5151 }
5152
5153
5154 //section size
5155
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&tempsize,f,true))
5156 {
5157 return qe_invalid;
5158 }
5159
5160 //finally... section data
5161 62 readsize=0;
5162
5163
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.text,f,true))
5164 {
5165 return qe_invalid;
5166 }
5167
5168
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.caption,f,true))
5169 {
5170 return qe_invalid;
5171 }
5172
5173
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5174 {
5175 return qe_invalid;
5176 }
5177
5178
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5179 {
5180 return qe_invalid;
5181 }
5182
5183
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5184 {
5185 return qe_invalid;
5186 }
5187
5188
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5189 {
5190 return qe_invalid;
5191 }
5192
5193
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5194 {
5195 return qe_invalid;
5196 }
5197
5198
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5199 {
5200 return qe_invalid;
5201 }
5202
5203
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5204 {
5205 return qe_invalid;
5206 }
5207
5208
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5209 {
5210 return qe_invalid;
5211 }
5212
5213
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5214 {
5215 return qe_invalid;
5216 }
5217
5218
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5219 {
5220 return qe_invalid;
5221 }
5222
5223
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5224 {
5225 return qe_invalid;
5226 }
5227
5228
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5229 {
5230 return qe_invalid;
5231 }
5232
5233
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5234 {
5235 return qe_invalid;
5236 }
5237
5238
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5239 {
5240 return qe_invalid;
5241 }
5242
5243
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5244 {
5245 return qe_invalid;
5246 }
5247
5248
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5249 {
5250 return qe_invalid;
5251 }
5252
5253
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5254 {
5255 return qe_invalid;
5256 }
5257
5258
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5259 {
5260 return qe_invalid;
5261 }
5262
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version < 4)
5263 {
5264
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&dummyw,f,true))
5265 return qe_invalid;
5266 59 temp_misc.colors.triforce_tile = dummyw;
5267
5268
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&dummyw,f,true))
5269 return qe_invalid;
5270 59 temp_misc.colors.triframe_tile = dummyw;
5271
5272
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&dummyw,f,true))
5273 return qe_invalid;
5274 59 temp_misc.colors.overworld_map_tile = dummyw;
5275
5276
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&dummyw,f,true))
5277 return qe_invalid;
5278 59 temp_misc.colors.dungeon_map_tile = dummyw;
5279
5280
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&dummyw,f,true))
5281 return qe_invalid;
5282 59 temp_misc.colors.blueframe_tile = dummyw;
5283
5284
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&dummyw,f,true))
5285 return qe_invalid;
5286 59 temp_misc.colors.HCpieces_tile = dummyw;
5287 59 }
5288
5289
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5290 {
5291 return qe_invalid;
5292 }
5293
5294
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5295 {
5296 return qe_invalid;
5297 }
5298
5299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(s_version < 2)
5300 {
5301 temp_misc.colors.msgtext = 0x01;
5302 }
5303 else
5304 {
5305
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_getc(&temp_misc.colors.msgtext, f, true))
5306 {
5307 return qe_invalid;
5308 }
5309 }
5310
5311
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if ( s_version >= 3 ) //expanded tile pages to 825
5312 {
5313
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&temp_misc.colors.triforce_tile,f,true))
5314 {
5315 return qe_invalid;
5316 }
5317
5318
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&temp_misc.colors.triframe_tile,f,true))
5319 {
5320 return qe_invalid;
5321 }
5322
5323
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f,true))
5324 {
5325 return qe_invalid;
5326 }
5327
5328
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f,true))
5329 {
5330 return qe_invalid;
5331 }
5332
5333
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&temp_misc.colors.blueframe_tile,f,true))
5334 {
5335 return qe_invalid;
5336 }
5337
5338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f,true))
5339 {
5340 return qe_invalid;
5341 }
5342 3 }
5343
5344
5345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata==true)
5346 {
5347 62 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5348 62 }
5349
5350 62 return 0;
5351 62 }
5352
5353 62 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc, bool keepdata)
5354 {
5355 miscQdata temp_misc;
5356 62 word s_version=0, s_cversion=0;
5357 byte icons;
5358 62 int32_t tempsize=0;
5359
5360 62 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5361
5362 //section version info
5363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(!p_igetw(&s_version,f,true))
5364 {
5365 return qe_invalid;
5366 }
5367
5368 62 FFCore.quest_format[vIcons] = s_version;
5369
5370 //al_trace("Game icons version %d\n", s_version);
5371
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_cversion,f,true))
5372 {
5373 return qe_invalid;
5374 }
5375
5376
5377 //section size
5378
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&tempsize,f,true))
5379 {
5380 return qe_invalid;
5381 }
5382
5383 //finally... section data
5384 62 readsize=0;
5385
5386 62 icons=4;
5387
5388
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if ( s_version >= 10 )
5389 {
5390
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<icons; i++)
5391 {
5392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_igetl(&temp_misc.icons[i],f,true))
5393 {
5394 return qe_invalid;
5395 }
5396 12 }
5397 3 }
5398 else
5399 {
5400
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 59 times.
295 for(int32_t i=0; i<icons; i++)
5401 {
5402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236 times.
236 if(!p_igetw(&temp_misc.icons[i],f,true))
5403 {
5404 return qe_invalid;
5405 }
5406 236 }
5407 }
5408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata==true)
5409 {
5410 62 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5411 62 }
5412
5413 62 return 0;
5414 62 }
5415
5416 62 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5417 {
5418 62 word maxinfos=256;
5419 62 word maxshops=256;
5420 62 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5421 62 word ponds=16, pondsize=72, expansionsize=98*2;
5422 byte tempbyte, padding;
5423 miscQdata temp_misc;
5424 62 word s_version=0, s_cversion=0;
5425 word swaptmp;
5426 62 int32_t tempsize=0;
5427
5428 62 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5429
5430
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<maxshops; ++i)
5431 {
5432 15872 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5433 15872 }
5434
5435
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<maxinfos; ++i)
5436 {
5437 15872 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5438 15872 }
5439
5440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(Header->zelda_version > 0x192)
5441 {
5442 //section version info
5443
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_version,f,true))
5444 {
5445 return qe_invalid;
5446 }
5447
5448 62 FFCore.quest_format[vMisc] = s_version;
5449
5450 //al_trace("Misc. data version %d\n", s_version);
5451
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_cversion,f,true))
5452 {
5453 return qe_invalid;
5454 }
5455
5456
5457 //section size
5458
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&tempsize,f,true))
5459 {
5460 return qe_invalid;
5461 }
5462 62 }
5463
5464 //finally... section data
5465 62 readsize=0;
5466
5467 //shops
5468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(Header->zelda_version > 0x192)
5469 {
5470
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&shops,f,true))
5471 {
5472 return qe_invalid;
5473 }
5474 62 }
5475
5476
2/2
✓ Branch 0 taken 551 times.
✓ Branch 1 taken 62 times.
613 for(int32_t i=0; i<shops; i++)
5477 {
5478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 551 times.
551 if(s_version > 6)
5479 {
5480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 551 times.
551 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f,true))
5481 {
5482 return qe_invalid;
5483 }
5484 551 }
5485
5486
2/2
✓ Branch 0 taken 1653 times.
✓ Branch 1 taken 551 times.
2204 for(int32_t j=0; j<3; j++)
5487 {
5488
1/2
✓ Branch 0 taken 1653 times.
✗ Branch 1 not taken.
1653 if(!p_getc(&temp_misc.shop[i].item[j],f,true))
5489 {
5490 return qe_invalid;
5491 }
5492
5493
1/2
✓ Branch 0 taken 1653 times.
✗ Branch 1 not taken.
1653 if(s_version < 4)
5494 {
5495 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5496 }
5497 1653 }
5498
5499
1/2
✓ Branch 0 taken 551 times.
✗ Branch 1 not taken.
551 if(Header->zelda_version < 0x193)
5500 {
5501 if(!p_getc(&tempbyte,f,true))
5502 {
5503 return qe_invalid;
5504 }
5505 }
5506
5507
2/2
✓ Branch 0 taken 1653 times.
✓ Branch 1 taken 551 times.
2204 for(int32_t j=0; j<3; j++)
5508 {
5509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1653 times.
1653 if(!p_igetw(&temp_misc.shop[i].price[j],f,true))
5510 {
5511 return qe_invalid;
5512 }
5513 1653 }
5514
5515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 551 times.
551 if(s_version > 3)
5516 {
5517
2/2
✓ Branch 0 taken 1653 times.
✓ Branch 1 taken 551 times.
2204 for(int32_t j=0; j<3; j++)
5518 {
5519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1653 times.
1653 if(!p_getc(&temp_misc.shop[i].hasitem[j],f,true))
5520 return qe_invalid;
5521 1653 }
5522 551 }
5523
5524 /*
5525 if(s_version < 8)
5526 {
5527 for(int32_t j=0; j<3; j++)
5528 {
5529 (&temp_misc.shop[i].str[j])=0; //initialise.
5530 }
5531 }
5532 */
5533 551 }
5534
5535 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5536
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<maxshops; ++i)
5537 {
5538
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 15872 times.
47616 for(int32_t j=0; j<3-1; j++)
5539 {
5540
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 31744 times.
79360 for(int32_t k=0; k<2-j; k++)
5541 {
5542
2/2
✓ Branch 0 taken 1436 times.
✓ Branch 1 taken 46180 times.
47616 if(temp_misc.shop[i].hasitem[k]==0)
5543 {
5544 46180 swaptmp = temp_misc.shop[i].item[k];
5545 46180 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5546 46180 temp_misc.shop[i].item[k+1] = swaptmp;
5547 46180 swaptmp = temp_misc.shop[i].price[k];
5548 46180 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5549 46180 temp_misc.shop[i].price[k+1] = swaptmp;
5550 46180 swaptmp = temp_misc.shop[i].hasitem[k];
5551 46180 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5552 46180 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5553 46180 }
5554 47616 }
5555 31744 }
5556 15872 }
5557
5558 //infos
5559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(Header->zelda_version > 0x192)
5560 {
5561
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&infos,f,true))
5562 {
5563 return qe_invalid;
5564 }
5565 62 }
5566
5567
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 62 times.
974 for(int32_t i=0; i<infos; i++)
5568 {
5569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 912 times.
912 if(s_version > 6)
5570 {
5571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 912 times.
912 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f,true))
5572 {
5573 return qe_invalid;
5574 }
5575 912 }
5576
5577
2/2
✓ Branch 0 taken 2736 times.
✓ Branch 1 taken 912 times.
3648 for(int32_t j=0; j<3; j++)
5578 {
5579
1/4
✓ Branch 0 taken 2736 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2736 if((Header->zelda_version < 0x192)||
5580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2736 times.
2736 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5581 {
5582 if(!p_getc(&tempbyte,f,true))
5583 {
5584 return qe_invalid;
5585 }
5586
5587 temp_misc.info[i].str[j]=tempbyte;
5588 }
5589 else
5590 {
5591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2736 times.
2736 if(!p_igetw(&temp_misc.info[i].str[j],f,true))
5592 {
5593 return qe_invalid;
5594 }
5595 }
5596 2736 }
5597
5598
1/2
✓ Branch 0 taken 912 times.
✗ Branch 1 not taken.
912 if(Header->zelda_version < 0x193)
5599 {
5600 if(!p_getc(&tempbyte,f,true))
5601 {
5602 return qe_invalid;
5603 }
5604 }
5605
5606
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 912 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
912 if((Header->zelda_version == 0x192)&&(Header->build>145))
5607 {
5608 if(!p_getc(&padding,f,true))
5609 {
5610 return qe_invalid;
5611 }
5612 }
5613
5614
2/2
✓ Branch 0 taken 2736 times.
✓ Branch 1 taken 912 times.
3648 for(int32_t j=0; j<3; j++)
5615 {
5616
1/2
✓ Branch 0 taken 2736 times.
✗ Branch 1 not taken.
2736 if(!p_igetw(&temp_misc.info[i].price[j],f,true))
5617 {
5618 return qe_invalid;
5619 }
5620 2736 }
5621 912 }
5622
5623 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5624
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<maxinfos; ++i)
5625 {
5626
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 15872 times.
47616 for(int32_t j=0; j<3-1; j++)
5627 {
5628
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 31744 times.
79360 for(int32_t k=0; k<2-j; k++)
5629 {
5630
2/2
✓ Branch 0 taken 1095 times.
✓ Branch 1 taken 46521 times.
47616 if(temp_misc.info[i].str[k]==0)
5631 {
5632 46521 swaptmp = temp_misc.info[i].str[k];
5633 46521 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5634 46521 temp_misc.info[i].str[k+1] = swaptmp;
5635 46521 swaptmp = temp_misc.info[i].price[k];
5636 46521 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5637 46521 temp_misc.info[i].price[k+1] = swaptmp;
5638 46521 }
5639 47616 }
5640 31744 }
5641 15872 }
5642
5643
5644 //warp rings
5645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(s_version > 5)
5646 62 warprings++;
5647
5648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(Header->zelda_version > 0x192)
5649 {
5650
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&warprings,f,true))
5651 {
5652 return qe_invalid;
5653 }
5654 62 }
5655
5656
2/2
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 62 times.
656 for(int32_t i=0; i<warprings; i++)
5657 {
5658
2/2
✓ Branch 0 taken 5346 times.
✓ Branch 1 taken 594 times.
5940 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5659 {
5660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5346 times.
5346 if(s_version <= 3)
5661 {
5662 if(!p_getc(&tempbyte,f,true))
5663 {
5664 return qe_invalid;
5665 }
5666
5667 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5668 }
5669 else
5670 {
5671
1/2
✓ Branch 0 taken 5346 times.
✗ Branch 1 not taken.
5346 if(!p_igetw(&temp_misc.warp[i].dmap[j],f,true))
5672 {
5673 return qe_invalid;
5674 }
5675 }
5676 5346 }
5677
5678
2/2
✓ Branch 0 taken 5346 times.
✓ Branch 1 taken 594 times.
5940 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5679 {
5680
1/2
✓ Branch 0 taken 5346 times.
✗ Branch 1 not taken.
5346 if(!p_getc(&temp_misc.warp[i].scr[j],f,true))
5681 {
5682 return qe_invalid;
5683 }
5684 5346 }
5685
5686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 594 times.
594 if(!p_getc(&temp_misc.warp[i].size,f,true))
5687 {
5688 return qe_invalid;
5689 }
5690
5691
1/2
✓ Branch 0 taken 594 times.
✗ Branch 1 not taken.
594 if(Header->zelda_version < 0x193)
5692 {
5693 if(!p_getc(&tempbyte,f,true))
5694 {
5695 return qe_invalid;
5696 }
5697 }
5698 594 }
5699
5700 //palette cycles
5701
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5702 {
5703 for(int32_t i=0; i<256; i++)
5704 {
5705 for(int32_t j=0; j<3; j++)
5706 {
5707 temp_misc.cycles[i][j].first=0;
5708 temp_misc.cycles[i][j].count=0;
5709 temp_misc.cycles[i][j].speed=0;
5710 }
5711 }
5712
5713 if((Header->zelda_version < 0x192)||
5714 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5715 {
5716 palcycles=16;
5717 }
5718
5719 for(int32_t i=0; i<palcycles; i++)
5720 {
5721 for(int32_t j=0; j<3; j++)
5722 {
5723 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
5724 {
5725 return qe_invalid;
5726 }
5727
5728 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
5729 {
5730 return qe_invalid;
5731 }
5732
5733 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
5734 {
5735 return qe_invalid;
5736 }
5737 }
5738 }
5739 }
5740
5741 //Wind warps are now just another warp ring.
5742
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version <= 5)
5743 {
5744 if(Header->zelda_version > 0x192)
5745 {
5746 if(!p_igetw(&windwarps,f,true))
5747 {
5748 return qe_invalid;
5749 }
5750 }
5751
5752 for(int32_t i=0; i<windwarps; i++)
5753 {
5754 if(s_version <= 3)
5755 {
5756 if(!p_getc(&tempbyte,f,true))
5757 {
5758 return qe_invalid;
5759 }
5760
5761 temp_misc.warp[8].dmap[i]=tempbyte;
5762 }
5763 else
5764 {
5765 if(!p_igetw(&temp_misc.warp[8].dmap[i],f,true))
5766 {
5767 return qe_invalid;
5768 }
5769 }
5770
5771 if(!p_getc(&temp_misc.warp[8].scr[i],f,true))
5772 {
5773 return qe_invalid;
5774 }
5775
5776 temp_misc.warp[8].size = 9;
5777
5778 if(s_version == 5)
5779 {
5780 if(!p_getc(&tempbyte,f,true))
5781 {
5782 return qe_invalid;
5783 }
5784 }
5785 }
5786 }
5787
5788
5789 //triforce pieces
5790
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 62 times.
558 for(int32_t i=0; i<triforces; i++)
5791 {
5792
1/2
✓ Branch 0 taken 496 times.
✗ Branch 1 not taken.
496 if(!p_getc(&temp_misc.triforce[i],f,true))
5793 {
5794 return qe_invalid;
5795 }
5796 496 }
5797
5798 //misc color data
5799
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version<3)
5800 {
5801 if(!p_getc(&temp_misc.colors.text,f,true))
5802 {
5803 return qe_invalid;
5804 }
5805
5806 if(!p_getc(&temp_misc.colors.caption,f,true))
5807 {
5808 return qe_invalid;
5809 }
5810
5811 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5812 {
5813 return qe_invalid;
5814 }
5815
5816 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5817 {
5818 return qe_invalid;
5819 }
5820
5821 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5822 {
5823 return qe_invalid;
5824 }
5825
5826 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5827 {
5828 return qe_invalid;
5829 }
5830
5831 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5832 {
5833 return qe_invalid;
5834 }
5835
5836 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5837 {
5838 return qe_invalid;
5839 }
5840
5841 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5842 {
5843 return qe_invalid;
5844 }
5845
5846 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5847 {
5848 return qe_invalid;
5849 }
5850
5851 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5852 {
5853 return qe_invalid;
5854 }
5855
5856 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5857 {
5858 return qe_invalid;
5859 }
5860
5861 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5862 {
5863 return qe_invalid;
5864 }
5865
5866 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5867 {
5868 return qe_invalid;
5869 }
5870
5871 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5872 {
5873 return qe_invalid;
5874 }
5875
5876 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5877 {
5878 return qe_invalid;
5879 }
5880
5881 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5882 {
5883 return qe_invalid;
5884 }
5885
5886 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5887 {
5888 return qe_invalid;
5889 }
5890
5891 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5892 {
5893 return qe_invalid;
5894 }
5895
5896 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5897 {
5898 return qe_invalid;
5899 }
5900
5901 if(!p_igetw(&temp_misc.colors.triforce_tile,f,true))
5902 {
5903 return qe_invalid;
5904 }
5905
5906 if(!p_igetw(&temp_misc.colors.triframe_tile,f,true))
5907 {
5908 return qe_invalid;
5909 }
5910
5911 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f,true))
5912 {
5913 return qe_invalid;
5914 }
5915
5916 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f,true))
5917 {
5918 return qe_invalid;
5919 }
5920
5921 if(!p_igetw(&temp_misc.colors.blueframe_tile,f,true))
5922 {
5923 return qe_invalid;
5924 }
5925
5926 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f,true))
5927 {
5928 return qe_invalid;
5929 }
5930
5931 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5932 {
5933 return qe_invalid;
5934 }
5935
5936 temp_misc.colors.msgtext = 0x01;
5937
5938 if(Header->zelda_version < 0x193)
5939 {
5940 for(int32_t i=0; i<7; i++)
5941 {
5942 if(!p_getc(&tempbyte,f,true))
5943 {
5944 return qe_invalid;
5945 }
5946 }
5947 }
5948
5949 if((Header->zelda_version == 0x192)&&(Header->build>145))
5950 {
5951 for(int32_t i=0; i<256; i++)
5952 {
5953 if(!p_getc(&tempbyte,f,true))
5954 {
5955 return qe_invalid;
5956 }
5957 }
5958 }
5959
5960 if(s_version>1)
5961 {
5962 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5963 {
5964 return qe_invalid;
5965 }
5966 }
5967
5968 //save game icons
5969 if((Header->zelda_version < 0x192)||
5970 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5971 {
5972 icons=3;
5973 }
5974
5975 for(int32_t i=0; i<icons; i++)
5976 {
5977 if(!p_igetw(&temp_misc.icons[i],f,true))
5978 {
5979 return qe_invalid;
5980 }
5981 }
5982 }
5983
5984
1/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 if((Header->zelda_version < 0x192)||
5985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ((Header->zelda_version == 0x192)&&(Header->build<30)))
5986 {
5987 if(keepdata==true)
5988 {
5989 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5990 }
5991
5992 return 0;
5993 }
5994
5995 //pond information
5996
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(Header->zelda_version < 0x193)
5997 {
5998 if((Header->zelda_version == 0x192)&&(Header->build<146))
5999 {
6000 pondsize=25;
6001 }
6002
6003 for(int32_t i=0; i<ponds; i++)
6004 {
6005 for(int32_t j=0; j<pondsize; j++)
6006 {
6007 if(!p_getc(&tempbyte,f,true))
6008 {
6009 return qe_invalid;
6010
6011 }
6012 }
6013 }
6014 }
6015
6016 //end string
6017
1/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 if((Header->zelda_version < 0x192)||
6018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6019 {
6020 if(!p_getc(&tempbyte,f,true))
6021 {
6022 return qe_invalid;
6023 }
6024
6025 temp_misc.endstring=tempbyte;
6026
6027 if(!p_getc(&tempbyte,f,true))
6028 {
6029 return qe_invalid;
6030 }
6031 }
6032 else
6033 {
6034
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&temp_misc.endstring,f,true))
6035 {
6036 return qe_invalid;
6037 }
6038 }
6039
6040 //expansion
6041
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(Header->zelda_version < 0x193)
6042 {
6043 if((Header->zelda_version == 0x192)&&(Header->build<73))
6044 {
6045 expansionsize=99*2;
6046 }
6047
6048 for(int32_t i=0; i<expansionsize; i++)
6049 {
6050 if(!p_getc(&tempbyte,f,true))
6051 {
6052 return qe_invalid;
6053 }
6054 }
6055 }
6056 //shops v8
6057
6058
6059
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if(s_version >= 8)
6060 {
6061
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 3 times.
51 for(int32_t i=0; i<shops; i++)
6062 {
6063
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 48 times.
192 for(int32_t j=0; j<3; j++)
6064 {
6065
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetw(&temp_misc.shop[i].str[j],f,true))
6066 return qe_invalid;
6067 144 }
6068 48 }
6069 3 }
6070
6071 62 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6072 62 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6073 62 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6074
6075 //v9 includes quest misc[32]
6076
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if(s_version >= 9)
6077 {
6078
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 for ( int32_t q = 0; q < 32; q++ )
6079 {
6080
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&temp_misc.questmisc[q],f,true))
6081 return qe_invalid;
6082 96 }
6083
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 for ( int32_t q = 0; q < 32; q++ )
6084 {
6085
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 96 times.
12384 for ( int32_t j = 0; j < 128; j++ )
6086
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_getc(&temp_misc.questmisc_strings[q][j],f,true))
6087 return qe_invalid;
6088 96 }
6089 3 }
6090
6091
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version >= 11 )
6092 {
6093
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f,true))
6094 return qe_invalid;
6095 3 }
6096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 else if(s_version < 11 )
6097 {
6098 59 temp_misc.zscript_last_compiled_version = -1;
6099 59 }
6100
6101 62 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6102
6103
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version >= 12)
6104 {
6105 byte spr;
6106
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t q = 0; q < sprMAX; ++q)
6107 {
6108
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&spr,f,true))
6109 return qe_invalid;
6110 768 temp_misc.sprites[q] = spr;
6111 768 }
6112 3 }
6113 else
6114 {
6115 59 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6116 //temp_misc.sprites[sprFALL] = ;
6117 }
6118
6119
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version >= 13)
6120 {
6121
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 3 times.
195 for(size_t q = 0; q < 64; ++q)
6122 {
6123 192 bottletype* bt = &(temp_misc.bottle_types[q]);
6124
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (!pfread(bt->name, 32, f, true))
6125 return qe_invalid;
6126
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 192 times.
768 for(size_t j = 0; j < 3; ++j)
6127 {
6128
1/2
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
576 if (!p_getc(&(bt->counter[j]), f, true))
6129 return qe_invalid;
6130
1/2
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
576 if (!p_igetw(&(bt->amount[j]), f, true))
6131 return qe_invalid;
6132 576 }
6133
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (!p_getc(&(bt->flags), f, true))
6134 return qe_invalid;
6135
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (!p_getc(&(bt->next_type), f, true))
6136 return qe_invalid;
6137 192 }
6138
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(size_t q = 0; q < 256; ++q)
6139 {
6140 768 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6141
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if (!pfread(bst->name, 32, f, true))
6142 return qe_invalid;
6143
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 768 times.
3072 for(size_t j = 0; j < 3; ++j)
6144 {
6145
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_getc(&(bst->fill[j]), f, true))
6146 return qe_invalid;
6147
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_igetw(&(bst->comb[j]), f, true))
6148 return qe_invalid;
6149
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_getc(&(bst->cset[j]), f, true))
6150 return qe_invalid;
6151
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_igetw(&(bst->price[j]), f, true))
6152 return qe_invalid;
6153
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_igetw(&(bst->str[j]), f, true))
6154 return qe_invalid;
6155 2304 }
6156 768 }
6157 3 }
6158 else
6159 {
6160
2/2
✓ Branch 0 taken 3776 times.
✓ Branch 1 taken 59 times.
3835 for(size_t q = 0; q < 64; ++q)
6161 3776 temp_misc.bottle_types[q].clear();
6162
2/2
✓ Branch 0 taken 15104 times.
✓ Branch 1 taken 59 times.
15163 for(size_t q = 0; q < 256; ++q)
6163 15104 temp_misc.bottle_shop_types[q].clear();
6164 }
6165
6166
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version >= 14)
6167 {
6168 byte msfx;
6169
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t q = 0; q < sfxMAX; ++q)
6170 {
6171
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&msfx,f,true))
6172 return qe_invalid;
6173 768 temp_misc.miscsfx[q] = msfx;
6174 768 }
6175 3 }
6176 else
6177 {
6178 59 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6179 59 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6180 59 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6181 }
6182
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version < 15)
6183 {
6184 59 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6185 59 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6186 59 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6187 59 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6188 59 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6189 59 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6190 59 }
6191
6192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata==true)
6193 {
6194 62 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6195 62 }
6196
6197 62 return 0;
6198 62 }
6199
6200 extern char *item_string[ITEMCNT];
6201 extern const char *old_item_string[iLast];
6202 extern char *weapon_string[WPNCNT];
6203 extern const char *old_weapon_string[wLast];
6204
6205 62 int32_t readitems(PACKFILE *f, word version, word build, bool keepdata, bool zgpmode)
6206 {
6207 byte padding;
6208 int32_t dummy;
6209 62 word items_to_read=MAXITEMS;
6210 itemdata tempitem;
6211 62 word s_version=0, s_cversion=0;
6212 word dummy_word;
6213
6214
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(version < 0x186)
6215 {
6216 items_to_read=64;
6217 }
6218
6219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(version > 0x192)
6220 {
6221 62 items_to_read=0;
6222
6223 //section version info
6224
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_version,f,true))
6225 {
6226 return qe_invalid;
6227 }
6228
6229 62 FFCore.quest_format[vItems] = s_version;
6230
6231 //al_trace("Items version %d\n", s_version);
6232
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_cversion,f,true))
6233 {
6234 return qe_invalid;
6235 }
6236
6237 //section size
6238
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&dummy,f,true))
6239 {
6240 return qe_invalid;
6241 }
6242
6243 //finally... section data
6244
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&items_to_read,f,true))
6245 {
6246 return qe_invalid;
6247 }
6248 62 }
6249
6250
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version>1)
6251 {
6252
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<items_to_read; i++)
6253 {
6254 char tempname[64];
6255
6256
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!pfread(tempname, 64, f, keepdata))
6257 {
6258 return qe_invalid;
6259 }
6260
6261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
15872 if(keepdata)
6262 {
6263 15872 strcpy(item_string[i], tempname);
6264 15872 }
6265 15872 }
6266 62 }
6267 else
6268 {
6269 if(keepdata)
6270 {
6271 for(int32_t i=0; i<ITEMCNT; i++)
6272 {
6273 reset_itemname(i);
6274 }
6275 }
6276 }
6277
6278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata)
6279 {
6280
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<MAXITEMS; i++)
6281 {
6282 15872 itemdata& id = itemsbuf[i];
6283 15872 memset(&id, 0, sizeof(itemdata));
6284 15872 id.count=-1;
6285 15872 id.playsound=WAV_SCALE;
6286 15872 reset_itembuf(&id,i);
6287 15872 }
6288 62 }
6289
6290
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<items_to_read; i++)
6291 {
6292 15872 memset(&tempitem, 0, sizeof(itemdata));
6293 15872 reset_itembuf(&tempitem,i);
6294
6295
6296
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if ( s_version > 35 ) //expanded tiles
6297 {
6298
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.tile,f,true))
6299 {
6300 return qe_invalid;
6301 }
6302 768 }
6303 else
6304 {
6305
1/2
✓ Branch 0 taken 15104 times.
✗ Branch 1 not taken.
15104 if(!p_igetw(&tempitem.tile,f,true))
6306 {
6307 return qe_invalid;
6308 }
6309 }
6310
6311
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.misc_flags,f,true))
6312 {
6313 return qe_invalid;
6314 }
6315
6316
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.csets,f,true))
6317 {
6318 return qe_invalid;
6319 }
6320
6321
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.frames,f,true))
6322 {
6323 return qe_invalid;
6324 }
6325
6326
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.speed,f,true))
6327 {
6328 return qe_invalid;
6329 }
6330
6331
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.delay,f,true))
6332 {
6333 return qe_invalid;
6334 }
6335
6336
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(version < 0x193)
6337 {
6338 if(!p_getc(&padding,f,true))
6339 {
6340 return qe_invalid;
6341 }
6342
6343 if((version < 0x192)||((version == 0x192)&&(build<186)))
6344 {
6345 switch(i)
6346 {
6347 case iShield:
6348 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-12:10;
6349 break;
6350
6351 case iMShield:
6352 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-6:-10;
6353 break;
6354
6355 default:
6356 tempitem.ltm=0;
6357 break;
6358 }
6359
6360 tempitem.count=-1;
6361 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6362 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6363 tempitem.family=0xFF;
6364 tempitem.playsound=WAV_SCALE;
6365 reset_itembuf(&tempitem,i);
6366
6367 if(keepdata==true)
6368 {
6369 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6370 }
6371
6372 continue;
6373 }
6374 }
6375
6376
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_igetl(&tempitem.ltm,f,true))
6377 {
6378 return qe_invalid;
6379 }
6380
6381
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(version < 0x193)
6382 {
6383 for(int32_t q=0; q<12; q++)
6384 {
6385 if(!p_getc(&padding,f,true))
6386 {
6387 return qe_invalid;
6388 }
6389 }
6390 }
6391
6392
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version>1)
6393 {
6394
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if ( s_version >= 31 )
6395 {
6396
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.family,f,true))
6397 {
6398 return qe_invalid;
6399 }
6400 768 }
6401 else
6402 {
6403
1/2
✓ Branch 0 taken 15104 times.
✗ Branch 1 not taken.
15104 if(!p_getc(&tempitem.family,f,true))
6404 {
6405 return qe_invalid;
6406 }
6407 }
6408
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 16)
6409 if(tempitem.family == 0xFF)
6410 tempitem.family = itype_misc;
6411
6412
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.fam_type,f,true))
6413 {
6414 return qe_invalid;
6415 }
6416
6417
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version>5)
6418 {
6419
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if(s_version>=31)
6420 {
6421
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.power,f,true))
6422 {
6423 return qe_invalid;
6424 }
6425 768 }
6426 else
6427 {
6428
1/2
✓ Branch 0 taken 15104 times.
✗ Branch 1 not taken.
15104 if(!p_getc(&tempitem.power,f,true))
6429 {
6430 return qe_invalid;
6431 }
6432 }
6433
6434 //converted flags from 16b to 32b -Z
6435
2/2
✓ Branch 0 taken 15104 times.
✓ Branch 1 taken 768 times.
15872 if ( s_version < 41 )
6436 {
6437
1/2
✓ Branch 0 taken 15104 times.
✗ Branch 1 not taken.
15104 if(!p_igetw(&tempitem.flags,f,true))
6438 {
6439 return qe_invalid;
6440 }
6441 15104 }
6442 else
6443 {
6444
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.flags,f,true))
6445 {
6446 return qe_invalid;
6447 }
6448 }
6449 15872 }
6450 else
6451 {
6452 //tempitem.power = tempitem.fam_type;
6453 char tempchar;
6454
6455 if(!p_getc(&tempchar,f,true))
6456 {
6457 return qe_invalid;
6458 }
6459
6460 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6461 }
6462
6463
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_igetw(&tempitem.script,f,true))
6464 {
6465 return qe_invalid;
6466 }
6467
6468
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version<=3)
6469 {
6470 if(tempitem.script > NUMSCRIPTITEM)
6471 {
6472 tempitem.script = 0;
6473 }
6474 }
6475
6476
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.count,f,true))
6477 {
6478 return qe_invalid;
6479 }
6480
6481
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_igetw(&tempitem.amount,f,true))
6482 {
6483 return qe_invalid;
6484 }
6485
6486
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_igetw(&tempitem.collect_script,f,true))
6487 {
6488 return qe_invalid;
6489 }
6490
6491
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version<=3)
6492 {
6493 if(tempitem.collect_script > NUMSCRIPTITEM)
6494 {
6495 tempitem.collect_script = 0;
6496 }
6497 }
6498
6499
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_igetw(&tempitem.setmax,f,true))
6500 {
6501 return qe_invalid;
6502 }
6503
6504
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_igetw(&tempitem.max,f,true))
6505 {
6506 return qe_invalid;
6507 }
6508
6509
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.playsound,f,true))
6510 {
6511 return qe_invalid;
6512 }
6513
6514
2/2
✓ Branch 0 taken 126976 times.
✓ Branch 1 taken 15872 times.
142848 for(int32_t j=0; j<8; j++)
6515 {
6516
1/2
✓ Branch 0 taken 126976 times.
✗ Branch 1 not taken.
126976 if(!p_igetl(&tempitem.initiald[j],f,true))
6517 {
6518 return qe_invalid;
6519 }
6520 126976 }
6521
6522
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 15872 times.
47616 for(int32_t j=0; j<2; j++)
6523 {
6524
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&tempitem.initiala[j],f,true))
6525 {
6526 return qe_invalid;
6527 }
6528 31744 }
6529
6530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
15872 if(s_version>4)
6531 {
6532
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version>5)
6533 {
6534
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.wpn,f,true))
6535 {
6536 return qe_invalid;
6537 }
6538
6539
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.wpn2,f,true))
6540 {
6541 return qe_invalid;
6542 }
6543
6544
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.wpn3,f,true))
6545 {
6546 return qe_invalid;
6547 }
6548
6549
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.wpn4,f,true))
6550 {
6551 return qe_invalid;
6552 }
6553
6554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
15872 if(s_version>=15)
6555 {
6556
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.wpn5,f,true))
6557 {
6558 return qe_invalid;
6559 }
6560
6561
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.wpn6,f,true))
6562 {
6563 return qe_invalid;
6564 }
6565
6566
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.wpn7,f,true))
6567 {
6568 return qe_invalid;
6569 }
6570
6571
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.wpn8,f,true))
6572 {
6573 return qe_invalid;
6574 }
6575
6576
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.wpn9,f,true))
6577 {
6578 return qe_invalid;
6579 }
6580
6581
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.wpn10,f,true))
6582 {
6583 return qe_invalid;
6584 }
6585 15872 }
6586
6587
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.pickup_hearts,f,true))
6588 {
6589 return qe_invalid;
6590 }
6591
6592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
15872 if(s_version<15)
6593 {
6594 if(!p_igetw(&dummy_word,f,true))
6595 {
6596 return qe_invalid;
6597 }
6598
6599 tempitem.misc1=dummy_word;
6600
6601 if(!p_igetw(&dummy_word,f,true))
6602 {
6603 return qe_invalid;
6604 }
6605
6606 tempitem.misc2=dummy_word;
6607 }
6608 else
6609 {
6610
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_igetl(&tempitem.misc1,f,true))
6611 {
6612 return qe_invalid;
6613 }
6614
6615
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_igetl(&tempitem.misc2,f,true))
6616 {
6617 return qe_invalid;
6618 }
6619
6620 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6621
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version<24)
6622 {
6623 if(tempitem.family==itype_shield)
6624 {
6625 tempitem.misc1|=shSCRIPT;
6626 }
6627 }
6628 }
6629
6630
2/2
✓ Branch 0 taken 15104 times.
✓ Branch 1 taken 768 times.
15872 if(s_version < 53)
6631 {
6632 byte tempbyte;
6633
1/2
✓ Branch 0 taken 15104 times.
✗ Branch 1 not taken.
15104 if(!p_getc(&tempbyte,f,true))
6634 {
6635 return qe_invalid;
6636 }
6637 15104 tempitem.cost_amount[0] = tempbyte;
6638 15104 }
6639 else
6640 {
6641
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 768 times.
2304 for(auto q = 0; q < 2; ++q)
6642 {
6643
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&tempitem.cost_amount[q],f,true))
6644 {
6645 return qe_invalid;
6646 }
6647 1536 }
6648 }
6649 15872 }
6650 else
6651 {
6652 char tempchar;
6653
6654 if(!p_getc(&tempchar,f,true))
6655 {
6656 return qe_invalid;
6657 }
6658
6659 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6660 }
6661
6662 // June 2007: more misc. attributes
6663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
15872 if(s_version>=12)
6664 {
6665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
15872 if(s_version<15)
6666 {
6667 if(!p_igetw(&dummy_word,f,true))
6668 {
6669 return qe_invalid;
6670 }
6671
6672 tempitem.misc3=dummy_word;
6673
6674 if(!p_igetw(&dummy_word,f,true))
6675 {
6676 return qe_invalid;
6677 }
6678
6679 tempitem.misc4=dummy_word;
6680 }
6681 else
6682 {
6683
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_igetl(&tempitem.misc3,f,true))
6684 {
6685 return qe_invalid;
6686 }
6687
6688
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_igetl(&tempitem.misc4,f,true))
6689 {
6690 return qe_invalid;
6691 }
6692
6693
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_igetl(&tempitem.misc5,f,true))
6694 {
6695 return qe_invalid;
6696 }
6697
6698
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_igetl(&tempitem.misc6,f,true))
6699 {
6700 return qe_invalid;
6701 }
6702
6703
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_igetl(&tempitem.misc7,f,true))
6704 {
6705 return qe_invalid;
6706 }
6707
6708
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_igetl(&tempitem.misc8,f,true))
6709 {
6710 return qe_invalid;
6711 }
6712
6713
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_igetl(&tempitem.misc9,f,true))
6714 {
6715 return qe_invalid;
6716 }
6717
6718
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_igetl(&tempitem.misc10,f,true))
6719 {
6720 return qe_invalid;
6721 }
6722 }
6723
6724
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempitem.usesound,f,true))
6725 {
6726 return qe_invalid;
6727 }
6728
6729
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if(s_version >= 49)
6730 {
6731
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&tempitem.usesound2,f,true))
6732 {
6733 return qe_invalid;
6734 }
6735 768 }
6736 15104 else tempitem.usesound2 = 0;
6737
6738
3/4
✓ Branch 0 taken 15104 times.
✓ Branch 1 taken 768 times.
✓ Branch 2 taken 15104 times.
✗ Branch 3 not taken.
15872 if(s_version < 50 && tempitem.family == itype_mirror)
6739 {
6740 //Split continue/dmap warp effect/sfx, port for old
6741 tempitem.misc2 = tempitem.misc1;
6742 tempitem.usesound2 = tempitem.usesound;
6743 }
6744 15872 }
6745 15872 }
6746
6747
2/2
✓ Branch 0 taken 15104 times.
✓ Branch 1 taken 768 times.
15872 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6748 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6749
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&tempitem.useweapon,f,true))
6750 {
6751 return qe_invalid;
6752 }
6753
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&tempitem.usedefence,f,true))
6754 {
6755 return qe_invalid;
6756 }
6757
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weaprange,f,true))
6758 {
6759 return qe_invalid;
6760 }
6761
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weapduration,f,true))
6762 {
6763 return qe_invalid;
6764 }
6765
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 768 times.
8448 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6766 {
6767
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.weap_pattern[q],f,true))
6768 {
6769 return qe_invalid;
6770 }
6771 7680 }
6772 768 }
6773
6774
2/2
✓ Branch 0 taken 15104 times.
✓ Branch 1 taken 768 times.
15872 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6775 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6776
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.duplicates,f,true))
6777 {
6778 return qe_invalid;
6779 }
6780
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 768 times.
6912 for ( int32_t q = 0; q < INITIAL_D; q++ )
6781 {
6782
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.weap_initiald[q],f,true))
6783 {
6784 return qe_invalid;
6785 }
6786 6144 }
6787
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 768 times.
2304 for ( int32_t q = 0; q < INITIAL_A; q++ )
6788 {
6789
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_getc(&tempitem.weap_initiala[q],f,true))
6790 {
6791 return qe_invalid;
6792 }
6793 1536 }
6794
6795
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&tempitem.drawlayer,f,true))
6796 {
6797 return qe_invalid;
6798 }
6799
6800
6801
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.hxofs,f,true))
6802 {
6803 return qe_invalid;
6804 }
6805
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.hyofs,f,true))
6806 {
6807 return qe_invalid;
6808 }
6809
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.hxsz,f,true))
6810 {
6811 return qe_invalid;
6812 }
6813
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.hysz,f,true))
6814 {
6815 return qe_invalid;
6816 }
6817
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.hzsz,f,true))
6818 {
6819 return qe_invalid;
6820 }
6821
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.xofs,f,true))
6822 {
6823 return qe_invalid;
6824 }
6825
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.yofs,f,true))
6826 {
6827 return qe_invalid;
6828 }
6829
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_hxofs,f,true))
6830 {
6831 return qe_invalid;
6832 }
6833
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_hyofs,f,true))
6834 {
6835 return qe_invalid;
6836 }
6837
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_hxsz,f,true))
6838 {
6839 return qe_invalid;
6840 }
6841
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_hysz,f,true))
6842 {
6843 return qe_invalid;
6844 }
6845
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_hzsz,f,true))
6846 {
6847 return qe_invalid;
6848 }
6849
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_xofs,f,true))
6850 {
6851 return qe_invalid;
6852 }
6853
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_yofs,f,true))
6854 {
6855 return qe_invalid;
6856 }
6857
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetw(&tempitem.weaponscript,f,true))
6858 {
6859 return qe_invalid;
6860 }
6861
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.wpnsprite,f,true))
6862 {
6863 return qe_invalid;
6864 }
6865 768 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6866
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 768 times.
2304 for(auto q = 0; q < num_cost_tmr; ++q)
6867 {
6868
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&tempitem.magiccosttimer[q],f,true))
6869 {
6870 return qe_invalid;
6871 }
6872 1536 }
6873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 for(auto q = num_cost_tmr; q < 2; ++q)
6874 tempitem.magiccosttimer[q] = 0;
6875 768 }
6876
2/2
✓ Branch 0 taken 15104 times.
✓ Branch 1 taken 768 times.
15872 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6877 {
6878 //Item Size FLags, TileWidth, TileHeight
6879
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.overrideFLAGS,f,true))
6880 {
6881 return qe_invalid;
6882 }
6883
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.tilew,f,true))
6884 {
6885 return qe_invalid;
6886 }
6887
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.tileh,f,true))
6888 {
6889 return qe_invalid;
6890 }
6891 768 }
6892
2/2
✓ Branch 0 taken 15104 times.
✓ Branch 1 taken 768 times.
15872 if ( s_version >= 29 ) //! More new vars.
6893 {
6894 //Item Size FLags, TileWidth, TileHeight
6895
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weapoverrideFLAGS,f,true))
6896 {
6897 return qe_invalid;
6898 }
6899
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_tilew,f,true))
6900 {
6901 return qe_invalid;
6902 }
6903
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.weap_tileh,f,true))
6904 {
6905 return qe_invalid;
6906 }
6907 768 }
6908
2/2
✓ Branch 0 taken 15104 times.
✓ Branch 1 taken 768 times.
15872 if ( s_version >= 30 ) //! More new vars.
6909 {
6910 //Pickup Type
6911
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempitem.pickup,f,true))
6912 {
6913 return qe_invalid;
6914 }
6915 768 }
6916
2/2
✓ Branch 0 taken 15104 times.
✓ Branch 1 taken 768 times.
15872 if ( s_version >= 32 ) //! More new vars.
6917 {
6918 //Pickup Type
6919
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetw(&tempitem.pstring,f,true))
6920 {
6921 return qe_invalid;
6922 }
6923 768 }
6924
2/2
✓ Branch 0 taken 15104 times.
✓ Branch 1 taken 768 times.
15872 if ( s_version >= 33 ) //! More new vars.
6925 {
6926 //Pickup Type
6927
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetw(&tempitem.pickup_string_flags,f,true))
6928 {
6929 return qe_invalid;
6930 }
6931 768 }
6932
2/2
✓ Branch 0 taken 15104 times.
✓ Branch 1 taken 768 times.
15872 if ( s_version >= 34 ) //! cost counter
6933 {
6934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(s_version < 53)
6935 {
6936 if(!p_getc(&tempitem.cost_counter[0],f,true))
6937 {
6938 return qe_invalid;
6939 }
6940 }
6941 else
6942 {
6943
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 768 times.
2304 for(auto q = 0; q < 2; ++q)
6944 {
6945
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_getc(&tempitem.cost_counter[q],f,true))
6946 {
6947 return qe_invalid;
6948 }
6949 1536 }
6950 }
6951 768 }
6952
2/2
✓ Branch 0 taken 15104 times.
✓ Branch 1 taken 768 times.
15872 if ( s_version >= 44 ) //! sprite scripts
6953 {
6954
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 768 times.
6912 for ( int32_t q = 0; q < 8; q++ )
6955 {
6956
2/2
✓ Branch 0 taken 399360 times.
✓ Branch 1 taken 6144 times.
405504 for ( int32_t w = 0; w < 65; w++ )
6957 {
6958
1/2
✓ Branch 0 taken 399360 times.
✗ Branch 1 not taken.
399360 if(!p_getc(&(tempitem.initD_label[q][w]),f,keepdata))
6959 {
6960 return qe_invalid;
6961 }
6962 399360 }
6963
2/2
✓ Branch 0 taken 399360 times.
✓ Branch 1 taken 6144 times.
405504 for ( int32_t w = 0; w < 65; w++ )
6964 {
6965
1/2
✓ Branch 0 taken 399360 times.
✗ Branch 1 not taken.
399360 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f,keepdata))
6966 {
6967 return qe_invalid;
6968 }
6969 399360 }
6970
2/2
✓ Branch 0 taken 399360 times.
✓ Branch 1 taken 6144 times.
405504 for ( int32_t w = 0; w < 65; w++ )
6971 {
6972
1/2
✓ Branch 0 taken 399360 times.
✗ Branch 1 not taken.
399360 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f,keepdata))
6973 {
6974 return qe_invalid;
6975 }
6976 399360 }
6977
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&(tempitem.sprite_initiald[q]),f,keepdata))
6978 {
6979 return qe_invalid;
6980 }
6981
6982 6144 }
6983
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 768 times.
2304 for ( int32_t q = 0; q < 2; q++ )
6984 {
6985
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_getc(&(tempitem.sprite_initiala[q]),f,keepdata))
6986 {
6987 return qe_invalid;
6988 }
6989 1536 }
6990 //Pickup Type
6991
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetw(&tempitem.sprite_script,f,true))
6992 {
6993 return qe_invalid;
6994 }
6995 768 }
6996
2/2
✓ Branch 0 taken 15104 times.
✓ Branch 1 taken 768 times.
15872 if ( s_version >= 48 ) //! pickup flags
6997 {
6998
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&(tempitem.pickupflag),f,keepdata))
6999 {
7000 return qe_invalid;
7001 }
7002 768 }
7003 15872 }
7004 else
7005 {
7006 tempitem.count=-1;
7007 tempitem.family=itype_misc;
7008 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7009 tempitem.playsound=WAV_SCALE;
7010 reset_itembuf(&tempitem,i);
7011 }
7012
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if(s_version < 53)
7013 {
7014
4/4
✓ Branch 0 taken 14799 times.
✓ Branch 1 taken 177 times.
✓ Branch 2 taken 69 times.
✓ Branch 3 taken 59 times.
15104 switch(tempitem.family)
7015 {
7016 case itype_arrow:
7017 177 tempitem.cost_counter[1] = crARROWS;
7018 177 tempitem.cost_amount[1] = 1;
7019 177 break;
7020 case itype_bomb:
7021 69 tempitem.cost_counter[1] = crBOMBS;
7022 69 tempitem.cost_amount[1] = 1;
7023 69 break;
7024 case itype_sbomb:
7025 59 tempitem.cost_counter[1] = crSBOMBS;
7026 59 tempitem.cost_amount[1] = 1;
7027 59 break;
7028 default:
7029 14799 tempitem.cost_counter[1] = crNONE;
7030 14799 tempitem.cost_amount[1] = 0;
7031 14799 }
7032 15104 tempitem.magiccosttimer[1] = 0;
7033 15104 }
7034
7035
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(keepdata==true)
7036 {
7037 15872 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7038 15872 }
7039 else if(zgpmode)
7040 {
7041 itemsbuf[i].tile=tempitem.tile;
7042 itemsbuf[i].misc_flags=tempitem.misc_flags;
7043 itemsbuf[i].csets=tempitem.csets;
7044 itemsbuf[i].frames=tempitem.frames;
7045 itemsbuf[i].speed=tempitem.speed;
7046 itemsbuf[i].delay=tempitem.delay;
7047 itemsbuf[i].ltm=tempitem.ltm;
7048 }
7049 15872 }
7050
7051 //////////////////////////////////////////////////////
7052 // Now do any updates because of new item additions
7053 // (These can't be done above because items_to_read
7054 // might be too low.)
7055 //////////////////////////////////////////////////////
7056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata==true)
7057 {
7058
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<MAXITEMS; i++)
7059 {
7060 15872 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7061
7062 //Account for older quests that didn't have an actual item for the used letter
7063
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15872 if(s_version < 2 && i==iLetterUsed)
7064 {
7065 reset_itembuf(&tempitem, iLetterUsed);
7066 strcpy(item_string[i],old_item_string[i]);
7067 tempitem.tile = itemsbuf[iLetter].tile;
7068 tempitem.csets = itemsbuf[iLetter].csets;
7069 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7070 tempitem.frames = itemsbuf[iLetter].frames;
7071 tempitem.speed = itemsbuf[iLetter].speed;
7072 tempitem.ltm = itemsbuf[iLetter].ltm;
7073 }
7074
7075
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 3)
7076 {
7077 switch(i)
7078 {
7079 case iRocsFeather:
7080 case iHoverBoots:
7081 case iSpinScroll:
7082 case iL2SpinScroll:
7083 case iCrossScroll:
7084 case iQuakeScroll:
7085 case iL2QuakeScroll:
7086 case iWhispRing:
7087 case iL2WhispRing:
7088 case iChargeRing:
7089 case iL2ChargeRing:
7090 case iPerilScroll:
7091 case iWalletL3:
7092 case iQuiverL4:
7093 case iBombBagL4:
7094 case iBracelet:
7095 case iL2Bracelet:
7096 case iOldGlove:
7097 case iL2Ladder:
7098 case iWealthMedal:
7099 case iL2WealthMedal:
7100 case iL3WealthMedal:
7101 reset_itembuf(&tempitem, i);
7102 strcpy(item_string[i],old_item_string[i]);
7103 break;
7104
7105 case iSShield:
7106 reset_itembuf(&tempitem, i);
7107 strcpy(item_string[i],old_item_string[i]);
7108 strcpy(item_string[iShield],old_item_string[iShield]);
7109 strcpy(item_string[iMShield],old_item_string[iMShield]);
7110 break;
7111 }
7112 }
7113
7114
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 5)
7115 {
7116 switch(i)
7117 {
7118 case iHeartRing:
7119 case iL2HeartRing:
7120 case iL3HeartRing:
7121 case iMagicRing:
7122 case iL2MagicRing:
7123 case iL3MagicRing:
7124 case iL4MagicRing:
7125 reset_itembuf(&tempitem, i);
7126 strcpy(item_string[i],old_item_string[i]);
7127 break;
7128 }
7129 }
7130
7131
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7132 {
7133 if(i!=iBPotion && i!=iRPotion)
7134 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7135
7136 switch(i)
7137 {
7138 case iTriforce:
7139 tempitem.fam_type=1;
7140 break;
7141
7142 case iBigTri:
7143 tempitem.fam_type=0;
7144 break;
7145
7146 case iBombs:
7147 tempitem.fam_type=i_bomb;
7148 tempitem.power=4;
7149 tempitem.wpn=wBOMB;
7150 tempitem.wpn2=wBOOM;
7151 tempitem.misc1 = 50;
7152
7153 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 200; //qr_SLOWBOMBFUSES
7154
7155 break;
7156
7157 case iSBomb:
7158 tempitem.fam_type=i_sbomb;
7159 tempitem.power=16;
7160 tempitem.wpn=wSBOMB;
7161 tempitem.wpn2=wSBOOM;
7162 tempitem.misc1 = 50;
7163
7164 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 400; //qr_SLOWBOMBFUSES
7165
7166 break;
7167
7168 case iBook:
7169 if(get_bit(deprecated_rules, 113))
7170 tempitem.wpn = wFIREMAGIC; //qr_FIREMAGICSPRITE
7171
7172 break;
7173
7174 case iSArrow:
7175 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7176 tempitem.power=4;
7177 tempitem.flags|=ITEM_GAMEDATA;
7178 tempitem.wpn=wSARROW;
7179 break;
7180
7181 case iGArrow:
7182 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7183 tempitem.power=8;
7184 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7185 tempitem.wpn=wGARROW;
7186 break;
7187
7188 case iBrang:
7189 tempitem.power=0;
7190 tempitem.wpn=wBRANG;
7191 tempitem.misc1=36;
7192 break;
7193
7194 case iMBrang:
7195 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7196 tempitem.power=0;
7197 tempitem.wpn=wMBRANG;
7198 break;
7199
7200 case iFBrang:
7201 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7202 tempitem.power=2;
7203 tempitem.wpn=wFBRANG;
7204 break;
7205
7206 case iBoots:
7207 tempitem.cost_amount[0] = get_bit(deprecated_rules,51) ? 1 : 0;
7208 tempitem.power=7;
7209 break;
7210
7211 case iWand:
7212 tempitem.cost_amount[0] = get_bit(deprecated_rules,49) ? 8 : 0;
7213 tempitem.power=2;
7214 tempitem.wpn=wWAND;
7215 tempitem.wpn3=wMAGIC;
7216 break;
7217
7218 case iBCandle:
7219 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7220 tempitem.power=1;
7221 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7222 tempitem.wpn3=wFIRE;
7223 break;
7224
7225 case iRCandle:
7226 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7227 tempitem.power=1;
7228 tempitem.wpn3=wFIRE;
7229 break;
7230
7231 case iSword:
7232 tempitem.power=1;
7233 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7234 tempitem.wpn=tempitem.wpn3=wSWORD;
7235 tempitem.wpn2=wSWORDSLASH;
7236 break;
7237
7238 case iWSword:
7239 tempitem.power=2;
7240 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7241 tempitem.wpn=tempitem.wpn3=wWSWORD;
7242 tempitem.wpn2=wWSWORDSLASH;
7243 break;
7244
7245 case iMSword:
7246 tempitem.power=4;
7247 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7248 tempitem.wpn=tempitem.wpn3=wMSWORD;
7249 tempitem.wpn2=wMSWORDSLASH;
7250 break;
7251
7252 case iXSword:
7253 tempitem.power=8;
7254 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7255 tempitem.wpn=tempitem.wpn3=wXSWORD;
7256 tempitem.wpn2=wXSWORDSLASH;
7257 break;
7258
7259 case iNayrusLove:
7260 tempitem.flags |= get_bit(deprecated_rules,76) ? ITEM_FLAG1 : 0;
7261 tempitem.flags |= get_bit(deprecated_rules,75) ? ITEM_FLAG2 : 0;
7262 tempitem.wpn=wNAYRUSLOVE1A;
7263 tempitem.wpn2=wNAYRUSLOVE1B;
7264 tempitem.wpn3=wNAYRUSLOVES1A;
7265 tempitem.wpn4=wNAYRUSLOVES1B;
7266 tempitem.wpn6=wNAYRUSLOVE2A;
7267 tempitem.wpn7=wNAYRUSLOVE2B;
7268 tempitem.wpn8=wNAYRUSLOVES2A;
7269 tempitem.wpn9=wNAYRUSLOVES2B;
7270 tempitem.wpn5 = iwNayrusLoveShieldFront;
7271 tempitem.wpn10 = iwNayrusLoveShieldBack;
7272 tempitem.misc1=512;
7273 tempitem.cost_amount[0]=64;
7274 break;
7275
7276 case iLens:
7277 tempitem.misc1=60;
7278 tempitem.flags |= get_bit(quest_rules,qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7279 tempitem.cost_amount[0] = get_bit(quest_rules,qr_ENABLEMAGIC) ? 2 : 1;
7280 break;
7281
7282 case iArrow:
7283 tempitem.power=2;
7284 tempitem.wpn=wARROW;
7285 break;
7286
7287 case iHoverBoots:
7288 tempitem.misc1=45;
7289 tempitem.wpn=iwHover;
7290 break;
7291
7292 case iDinsFire:
7293 tempitem.power=8;
7294 tempitem.wpn=wDINSFIRE1A;
7295 tempitem.wpn2=wDINSFIRE1B;
7296 tempitem.wpn3=wDINSFIRES1A;
7297 tempitem.wpn4=wDINSFIRES1B;
7298 tempitem.misc1 = 32;
7299 tempitem.misc2 = 200;
7300 tempitem.cost_amount[0]=32;
7301 break;
7302
7303 case iFaroresWind:
7304 tempitem.cost_amount[0]=32;
7305 break;
7306
7307 case iHookshot:
7308 tempitem.power=0;
7309 tempitem.flags&=~ITEM_FLAG1;
7310 tempitem.wpn=wHSHEAD;
7311 tempitem.wpn2=wHSCHAIN_H;
7312 tempitem.wpn4=wHSHANDLE;
7313 tempitem.wpn3=wHSCHAIN_V;
7314 tempitem.misc1=50;
7315 tempitem.misc2=100;
7316 break;
7317
7318 case iLongshot:
7319 tempitem.power=0;
7320 tempitem.flags&=~ITEM_FLAG1;
7321 tempitem.wpn=wLSHEAD;
7322 tempitem.wpn2=wLSCHAIN_H;
7323 tempitem.wpn4=wLSHANDLE;
7324 tempitem.wpn3=wLSCHAIN_V;
7325 tempitem.misc1=99;
7326 tempitem.misc2=100;
7327 break;
7328
7329 case iHammer:
7330 tempitem.power=4;
7331 tempitem.wpn=wHAMMER;
7332 tempitem.wpn2=iwHammerSmack;
7333 break;
7334
7335 case iCByrna:
7336 tempitem.power=1;
7337 tempitem.wpn=wCBYRNA;
7338 tempitem.wpn2=wCBYRNASLASH;
7339 tempitem.wpn3=wCBYRNAORB;
7340 tempitem.misc1=4;
7341 tempitem.misc2=16;
7342 tempitem.misc3=1;
7343 tempitem.cost_amount[0]=1;
7344 break;
7345
7346 case iWhistle:
7347 tempitem.wpn=wWIND;
7348 tempitem.misc1=3;
7349 tempitem.flags|=ITEM_FLAG1;
7350 break;
7351
7352 case iBRing:
7353 tempitem.power=2;
7354 tempitem.misc1=spBLUE;
7355 break;
7356
7357 case iRRing:
7358 tempitem.power=4;
7359 tempitem.misc1=spRED;
7360 break;
7361
7362 case iGRing:
7363 tempitem.power=8;
7364 tempitem.misc1=spGOLD;
7365 break;
7366
7367 case iSpinScroll:
7368 tempitem.power = 2;
7369 tempitem.misc1 = 1;
7370 break;
7371
7372 case iL2SpinScroll:
7373 tempitem.family=itype_spinscroll2;
7374 tempitem.fam_type=1;
7375 tempitem.cost_amount[0]=8;
7376 tempitem.power=2;
7377 tempitem.misc1 = 20;
7378 break;
7379
7380 case iQuakeScroll:
7381 tempitem.misc1=0x10;
7382 tempitem.misc2=64;
7383 break;
7384
7385 case iL2QuakeScroll:
7386 tempitem.family=itype_quakescroll2;
7387 tempitem.fam_type=1;
7388 tempitem.power = 2;
7389 tempitem.misc1=0x20;
7390 tempitem.misc2=192;
7391 tempitem.cost_amount[0]=8;
7392 break;
7393
7394 case iChargeRing:
7395 tempitem.misc1=64;
7396 tempitem.misc2=128;
7397 break;
7398
7399 case iL2ChargeRing:
7400 tempitem.misc1=32;
7401 tempitem.misc2=64;
7402 break;
7403
7404 case iOldGlove:
7405 tempitem.flags |= ITEM_FLAG1;
7406
7407 //fallthrough
7408 case iBombBagL4:
7409 case iWalletL3:
7410 case iQuiverL4:
7411 case iBracelet:
7412 tempitem.power = 1;
7413 break;
7414
7415 case iL2Bracelet:
7416 tempitem.power = 2;
7417 break;
7418
7419 case iMKey:
7420 tempitem.power=0xFF;
7421 tempitem.flags |= ITEM_FLAG1;
7422 break;
7423 }
7424 }
7425
7426
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 7)
7427 {
7428 switch(i)
7429 {
7430 case iStoneAgony:
7431 case iStompBoots:
7432 case iPerilRing:
7433 case iWhimsicalRing:
7434 {
7435 reset_itembuf(&tempitem, i);
7436 strcpy(item_string[i],old_item_string[i]);
7437 break;
7438 }
7439 }
7440 }
7441
7442
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 8) // May 2007: Some corrections.
7443 {
7444 switch(i)
7445 {
7446 case iMShield:
7447 tempitem.misc1|=shFLAME;
7448 tempitem.misc2|=shFIREBALL|shMAGIC;
7449
7450 if(get_bit(quest_rules, qr_SWORDMIRROR))
7451 {
7452 tempitem.misc2 |= shSWORD;
7453 }
7454
7455 // fallthrough
7456 case iShield:
7457 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7458
7459 // fallthrough
7460 case iSShield:
7461 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7462
7463 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7464 {
7465 tempitem.misc2 |= shROCK;
7466 }
7467
7468 break;
7469
7470 case iWhispRing:
7471 tempitem.power=1;
7472 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7473 tempitem.misc1 = 3;
7474 break;
7475
7476 case iL2WhispRing:
7477 tempitem.power=0;
7478 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7479 tempitem.misc1 = 3;
7480 break;
7481
7482 case iL2Ladder:
7483 case iBow:
7484 case iCByrna:
7485 tempitem.power = 1;
7486 break;
7487 }
7488 }
7489
7490
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15872 if(s_version < 9 && i==iClock)
7491 {
7492 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7493 }
7494
7495 //add the misc flag for bomb
7496
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15872 if(s_version < 10 && tempitem.family == itype_bomb)
7497 {
7498 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_bit(quest_rules, qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7499 }
7500
7501
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15872 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7502 {
7503 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7504 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7505 }
7506
7507
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 12) // June 2007: More Misc. attributes.
7508 {
7509 switch(i)
7510 {
7511 case iFBrang:
7512 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7513
7514 //fallthrough
7515 case iMBrang:
7516 tempitem.misc3 |= shSWORD|shMAGIC;
7517
7518 //fallthrough
7519 case iHookshot:
7520 case iLongshot:
7521 //fallthrough
7522 tempitem.misc3 |= shFIREBALL;
7523
7524 case iBrang:
7525 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7526 break;
7527 }
7528
7529 switch(tempitem.family)
7530 {
7531 case itype_hoverboots:
7532 tempitem.usesound = WAV_ZN1HOVER;
7533 break;
7534
7535 case itype_wand:
7536 case itype_book:
7537 tempitem.usesound = WAV_WAND;
7538 break;
7539
7540 case itype_arrow:
7541 tempitem.usesound = WAV_ARROW;
7542 break;
7543
7544 case itype_hookshot:
7545 tempitem.usesound = WAV_HOOKSHOT;
7546 break;
7547
7548 case itype_brang:
7549 tempitem.usesound = WAV_BRANG;
7550 break;
7551
7552 case itype_shield:
7553 tempitem.usesound = WAV_CHINK;
7554 break;
7555
7556 case itype_sword:
7557 tempitem.usesound = WAV_SWORD;
7558 break;
7559
7560 case itype_whistle:
7561 tempitem.usesound = WAV_WHISTLE;
7562 break;
7563
7564 case itype_hammer:
7565 tempitem.usesound = WAV_HAMMER;
7566 break;
7567
7568 case itype_dinsfire:
7569 tempitem.usesound = WAV_ZN1DINSFIRE;
7570 break;
7571
7572 case itype_faroreswind:
7573 tempitem.usesound = WAV_ZN1FARORESWIND;
7574 break;
7575
7576 case itype_nayruslove:
7577 tempitem.usesound = WAV_ZN1NAYRUSLOVE1;
7578 break;
7579
7580 case itype_bomb:
7581 case itype_sbomb:
7582 case itype_quakescroll:
7583 case itype_quakescroll2:
7584 tempitem.usesound = WAV_BOMB;
7585 break;
7586
7587 case itype_spinscroll:
7588 case itype_spinscroll2:
7589 tempitem.usesound = WAV_ZN1SPINATTACK;
7590 break;
7591 }
7592 }
7593
7594
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 13) // July 2007
7595 {
7596 if(tempitem.family == itype_whistle)
7597 {
7598 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7599 tempitem.power = 1;
7600 tempitem.flags|=ITEM_FLAG1;
7601 }
7602 else if(tempitem.family == itype_wand)
7603 tempitem.flags|=ITEM_FLAG1;
7604 else if(tempitem.family == itype_book)
7605 {
7606 tempitem.flags|=ITEM_FLAG1;
7607 tempitem.power = 2;
7608 }
7609 }
7610
7611
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 14) // August 2007
7612 {
7613 if(tempitem.family == itype_fairy)
7614 {
7615 tempitem.usesound = WAV_SCALE;
7616
7617 if(tempitem.fam_type)
7618 tempitem.misc3=50;
7619 }
7620 else if(tempitem.family == itype_potion)
7621 {
7622 tempitem.flags |= ITEM_GAINOLD;
7623 }
7624 }
7625
7626
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 17) // November 2007
7627 {
7628 if(tempitem.family == itype_candle && !tempitem.wpn3)
7629 {
7630 tempitem.wpn3 = wFIRE;
7631 }
7632 else if(tempitem.family == itype_arrow && tempitem.power>4)
7633 {
7634 tempitem.flags|=ITEM_FLAG1;
7635 }
7636 }
7637
7638
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 18) // New Year's Eve 2007
7639 {
7640 if(tempitem.family == itype_whistle)
7641 tempitem.misc2 = 8; // Use the Whistle warp ring
7642 else if(tempitem.family == itype_bait)
7643 tempitem.misc1 = 768; // Frames until it goes
7644 else if(tempitem.family == itype_triforcepiece)
7645 {
7646 if(tempitem.flags & ITEM_GAMEDATA)
7647 {
7648 tempitem.misc2 = 1; // Cutscene 1
7649 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7650 }
7651 }
7652 }
7653
7654
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 19) // January 2008
7655 {
7656 if(tempitem.family == itype_nayruslove)
7657 {
7658 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7659 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7660 }
7661 }
7662
7663
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 20) // October 2008
7664 {
7665 if(tempitem.family == itype_nayruslove)
7666 {
7667 tempitem.wpn6=wNAYRUSLOVE2A;
7668 tempitem.wpn7=wNAYRUSLOVE2B;
7669 tempitem.wpn8=wNAYRUSLOVES2A;
7670 tempitem.wpn9=wNAYRUSLOVES2B;
7671 tempitem.wpn5 = iwNayrusLoveShieldFront;
7672 tempitem.wpn10 = iwNayrusLoveShieldBack;
7673 }
7674 }
7675
7676
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 21) // November 2008
7677 {
7678 if(tempitem.flags & 0x0100) // ITEM_SLASH
7679 {
7680 tempitem.flags &= ~0x0100;
7681
7682 if(tempitem.family == itype_sword ||
7683 tempitem.family == itype_wand ||
7684 tempitem.family == itype_candle ||
7685 tempitem.family == itype_cbyrna)
7686 {
7687 tempitem.flags |= ITEM_FLAG4;
7688 }
7689 }
7690 }
7691
7692
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 22) // September 2009
7693 {
7694 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7695 {
7696 tempitem.misc3 = tempitem.power/2;
7697 }
7698 }
7699
7700
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 23) // March 2011
7701 {
7702 if(tempitem.family == itype_dinsfire)
7703 tempitem.wpn5 = wFIRE;
7704 else if(tempitem.family == itype_book)
7705 tempitem.wpn2 = wFIRE;
7706 }
7707
7708 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7709 // whether it was or not, and a lot of existing quests depended on the
7710 // incorrect behavior.
7711
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 25) // January 2012
7712 {
7713 if(tempitem.family == itype_bombbag)
7714 tempitem.flags |= 16;
7715
7716 if(tempitem.family == itype_dinsfire)
7717 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7718 }
7719
7720
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7721 {
7722
60/60
✓ Branch 0 taken 1359 times.
✓ Branch 1 taken 636 times.
✓ Branch 2 taken 177 times.
✓ Branch 3 taken 761 times.
✓ Branch 4 taken 1625 times.
✓ Branch 5 taken 5140 times.
✓ Branch 6 taken 177 times.
✓ Branch 7 taken 177 times.
✓ Branch 8 taken 151 times.
✓ Branch 9 taken 105 times.
✓ Branch 10 taken 59 times.
✓ Branch 11 taken 118 times.
✓ Branch 12 taken 118 times.
✓ Branch 13 taken 69 times.
✓ Branch 14 taken 177 times.
✓ Branch 15 taken 177 times.
✓ Branch 16 taken 118 times.
✓ Branch 17 taken 177 times.
✓ Branch 18 taken 118 times.
✓ Branch 19 taken 59 times.
✓ Branch 20 taken 118 times.
✓ Branch 21 taken 69 times.
✓ Branch 22 taken 59 times.
✓ Branch 23 taken 177 times.
✓ Branch 24 taken 59 times.
✓ Branch 25 taken 59 times.
✓ Branch 26 taken 118 times.
✓ Branch 27 taken 59 times.
✓ Branch 28 taken 59 times.
✓ Branch 29 taken 59 times.
✓ Branch 30 taken 59 times.
✓ Branch 31 taken 59 times.
✓ Branch 32 taken 69 times.
✓ Branch 33 taken 59 times.
✓ Branch 34 taken 59 times.
✓ Branch 35 taken 59 times.
✓ Branch 36 taken 59 times.
✓ Branch 37 taken 118 times.
✓ Branch 38 taken 236 times.
✓ Branch 39 taken 59 times.
✓ Branch 40 taken 59 times.
✓ Branch 41 taken 105 times.
✓ Branch 42 taken 236 times.
✓ Branch 43 taken 59 times.
✓ Branch 44 taken 59 times.
✓ Branch 45 taken 59 times.
✓ Branch 46 taken 59 times.
✓ Branch 47 taken 59 times.
✓ Branch 48 taken 118 times.
✓ Branch 49 taken 118 times.
✓ Branch 50 taken 59 times.
✓ Branch 51 taken 177 times.
✓ Branch 52 taken 177 times.
✓ Branch 53 taken 236 times.
✓ Branch 54 taken 59 times.
✓ Branch 55 taken 59 times.
✓ Branch 56 taken 59 times.
✓ Branch 57 taken 59 times.
✓ Branch 58 taken 59 times.
✓ Branch 59 taken 59 times.
15104 switch(tempitem.family)
7723 {
7724 case itype_sword:
7725 {
7726 5140 tempitem.flags &= ~(ITEM_FLAG5);
7727 5140 tempitem.misc3 = 0;
7728 5140 tempitem.misc4 = 0;
7729 5140 tempitem.misc5 = 0;
7730 5140 tempitem.misc6 = 0;
7731 5140 tempitem.misc7 = 0;
7732 5140 tempitem.misc8 = 0;
7733 5140 tempitem.misc9 = 0;
7734 5140 tempitem.misc10 = 0;
7735 5140 tempitem.wpn4 = 0;
7736 5140 tempitem.wpn5 = 0;
7737 5140 tempitem.wpn6 = 0;
7738 5140 tempitem.wpn7 = 0;
7739 5140 tempitem.wpn8 = 0;
7740 5140 tempitem.wpn9 = 0;
7741 5140 tempitem.wpn10 = 0;
7742 5140 break;
7743 }
7744 case itype_brang:
7745 {
7746 177 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7747 177 tempitem.misc2 = 0;
7748 177 tempitem.misc5 = 0;
7749 177 tempitem.misc6 = 0;
7750 177 tempitem.misc7 = 0;
7751 177 tempitem.misc8 = 0;
7752 177 tempitem.misc9 = 0;
7753 177 tempitem.misc10 = 0;
7754 177 tempitem.wpn4 = 0;
7755 177 tempitem.wpn5 = 0;
7756 177 tempitem.wpn6 = 0;
7757 177 tempitem.wpn7 = 0;
7758 177 tempitem.wpn8 = 0;
7759 177 tempitem.wpn9 = 0;
7760 177 tempitem.wpn10 = 0;
7761 177 break;
7762 }
7763 case itype_arrow:
7764 {
7765 177 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7766 177 tempitem.misc2 = 0;
7767 177 tempitem.misc3 = 0;
7768 177 tempitem.misc4 = 0;
7769 177 tempitem.misc5 = 0;
7770 177 tempitem.misc6 = 0;
7771 177 tempitem.misc7 = 0;
7772 177 tempitem.misc8 = 0;
7773 177 tempitem.misc9 = 0;
7774 177 tempitem.misc10 = 0;
7775 177 tempitem.wpn4 = 0;
7776 177 tempitem.wpn5 = 0;
7777 177 tempitem.wpn6 = 0;
7778 177 tempitem.wpn7 = 0;
7779 177 tempitem.wpn8 = 0;
7780 177 tempitem.wpn9 = 0;
7781 177 tempitem.wpn10 = 0;
7782 177 break;
7783 }
7784 case itype_candle:
7785 {
7786 151 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7787 151 tempitem.misc1 = 0;
7788 151 tempitem.misc2 = 0;
7789 151 tempitem.misc3 = 0;
7790 151 tempitem.misc4 = 0;
7791 151 tempitem.misc5 = 0;
7792 151 tempitem.misc6 = 0;
7793 151 tempitem.misc7 = 0;
7794 151 tempitem.misc8 = 0;
7795 151 tempitem.misc9 = 0;
7796 151 tempitem.misc10 = 0;
7797 151 tempitem.wpn4 = 0;
7798 151 tempitem.wpn5 = 0;
7799 151 tempitem.wpn6 = 0;
7800 151 tempitem.wpn7 = 0;
7801 151 tempitem.wpn8 = 0;
7802 151 tempitem.wpn9 = 0;
7803 151 tempitem.wpn10 = 0;
7804 151 break;
7805 }
7806 case itype_whistle:
7807 {
7808 105 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7809 105 tempitem.misc3 = 0;
7810 105 tempitem.misc4 = 0;
7811 105 tempitem.misc5 = 0;
7812 105 tempitem.misc6 = 0;
7813 105 tempitem.misc7 = 0;
7814 105 tempitem.misc8 = 0;
7815 105 tempitem.misc9 = 0;
7816 105 tempitem.misc10 = 0;
7817 105 tempitem.wpn2 = 0;
7818 105 tempitem.wpn3 = 0;
7819 105 tempitem.wpn4 = 0;
7820 105 tempitem.wpn5 = 0;
7821 105 tempitem.wpn6 = 0;
7822 105 tempitem.wpn7 = 0;
7823 105 tempitem.wpn8 = 0;
7824 105 tempitem.wpn9 = 0;
7825 105 tempitem.wpn10 = 0;
7826 105 break;
7827 }
7828 case itype_bait:
7829 {
7830 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7831 59 tempitem.misc2 = 0;
7832 59 tempitem.misc3 = 0;
7833 59 tempitem.misc4 = 0;
7834 59 tempitem.misc5 = 0;
7835 59 tempitem.misc6 = 0;
7836 59 tempitem.misc7 = 0;
7837 59 tempitem.misc8 = 0;
7838 59 tempitem.misc9 = 0;
7839 59 tempitem.misc10 = 0;
7840 59 tempitem.wpn2 = 0;
7841 59 tempitem.wpn3 = 0;
7842 59 tempitem.wpn4 = 0;
7843 59 tempitem.wpn5 = 0;
7844 59 tempitem.wpn6 = 0;
7845 59 tempitem.wpn7 = 0;
7846 59 tempitem.wpn8 = 0;
7847 59 tempitem.wpn9 = 0;
7848 59 tempitem.wpn10 = 0;
7849 59 break;
7850 }
7851 case itype_letter:
7852 {
7853 118 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7854 118 tempitem.misc1 = 0;
7855 118 tempitem.misc2 = 0;
7856 118 tempitem.misc3 = 0;
7857 118 tempitem.misc4 = 0;
7858 118 tempitem.misc5 = 0;
7859 118 tempitem.misc6 = 0;
7860 118 tempitem.misc7 = 0;
7861 118 tempitem.misc8 = 0;
7862 118 tempitem.misc9 = 0;
7863 118 tempitem.misc10 = 0;
7864 118 tempitem.wpn = 0;
7865 118 tempitem.wpn2 = 0;
7866 118 tempitem.wpn3 = 0;
7867 118 tempitem.wpn4 = 0;
7868 118 tempitem.wpn5 = 0;
7869 118 tempitem.wpn6 = 0;
7870 118 tempitem.wpn7 = 0;
7871 118 tempitem.wpn8 = 0;
7872 118 tempitem.wpn9 = 0;
7873 118 tempitem.wpn10 = 0;
7874 118 break;
7875 }
7876 case itype_potion:
7877 {
7878 118 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7879 118 tempitem.misc3 = 0;
7880 118 tempitem.misc4 = 0;
7881 118 tempitem.misc5 = 0;
7882 118 tempitem.misc6 = 0;
7883 118 tempitem.misc7 = 0;
7884 118 tempitem.misc8 = 0;
7885 118 tempitem.misc9 = 0;
7886 118 tempitem.misc10 = 0;
7887 118 tempitem.wpn = 0;
7888 118 tempitem.wpn2 = 0;
7889 118 tempitem.wpn3 = 0;
7890 118 tempitem.wpn4 = 0;
7891 118 tempitem.wpn5 = 0;
7892 118 tempitem.wpn6 = 0;
7893 118 tempitem.wpn7 = 0;
7894 118 tempitem.wpn8 = 0;
7895 118 tempitem.wpn9 = 0;
7896 118 tempitem.wpn10 = 0;
7897 118 break;
7898 }
7899 case itype_wand:
7900 {
7901 69 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
7902 69 tempitem.misc1 = 0;
7903 69 tempitem.misc2 = 0;
7904 69 tempitem.misc3 = 0;
7905 69 tempitem.misc4 = 0;
7906 69 tempitem.misc5 = 0;
7907 69 tempitem.misc6 = 0;
7908 69 tempitem.misc7 = 0;
7909 69 tempitem.misc8 = 0;
7910 69 tempitem.misc9 = 0;
7911 69 tempitem.misc10 = 0;
7912 69 tempitem.wpn4 = 0;
7913 69 tempitem.wpn5 = 0;
7914 69 tempitem.wpn6 = 0;
7915 69 tempitem.wpn7 = 0;
7916 69 tempitem.wpn8 = 0;
7917 69 tempitem.wpn9 = 0;
7918 69 tempitem.wpn10 = 0;
7919 69 break;
7920 }
7921 case itype_ring:
7922 {
7923 177 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7924 177 tempitem.misc2 = 0;
7925 177 tempitem.misc3 = 0;
7926 177 tempitem.misc4 = 0;
7927 177 tempitem.misc5 = 0;
7928 177 tempitem.misc6 = 0;
7929 177 tempitem.misc7 = 0;
7930 177 tempitem.misc8 = 0;
7931 177 tempitem.misc9 = 0;
7932 177 tempitem.misc10 = 0;
7933 177 tempitem.wpn = 0;
7934 177 tempitem.wpn2 = 0;
7935 177 tempitem.wpn3 = 0;
7936 177 tempitem.wpn4 = 0;
7937 177 tempitem.wpn5 = 0;
7938 177 tempitem.wpn6 = 0;
7939 177 tempitem.wpn7 = 0;
7940 177 tempitem.wpn8 = 0;
7941 177 tempitem.wpn9 = 0;
7942 177 tempitem.wpn10 = 0;
7943 177 break;
7944 }
7945 case itype_wallet:
7946 {
7947 177 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7948 177 tempitem.misc3 = 0;
7949 177 tempitem.misc4 = 0;
7950 177 tempitem.misc5 = 0;
7951 177 tempitem.misc6 = 0;
7952 177 tempitem.misc7 = 0;
7953 177 tempitem.misc8 = 0;
7954 177 tempitem.misc9 = 0;
7955 177 tempitem.misc10 = 0;
7956 177 tempitem.wpn = 0;
7957 177 tempitem.wpn2 = 0;
7958 177 tempitem.wpn3 = 0;
7959 177 tempitem.wpn4 = 0;
7960 177 tempitem.wpn5 = 0;
7961 177 tempitem.wpn6 = 0;
7962 177 tempitem.wpn7 = 0;
7963 177 tempitem.wpn8 = 0;
7964 177 tempitem.wpn9 = 0;
7965 177 tempitem.wpn10 = 0;
7966 177 break;
7967 }
7968 case itype_amulet:
7969 {
7970 118 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7971 118 tempitem.misc1 = 0;
7972 118 tempitem.misc2 = 0;
7973 118 tempitem.misc3 = 0;
7974 118 tempitem.misc4 = 0;
7975 118 tempitem.misc5 = 0;
7976 118 tempitem.misc6 = 0;
7977 118 tempitem.misc7 = 0;
7978 118 tempitem.misc8 = 0;
7979 118 tempitem.misc9 = 0;
7980 118 tempitem.misc10 = 0;
7981 118 tempitem.wpn = 0;
7982 118 tempitem.wpn2 = 0;
7983 118 tempitem.wpn3 = 0;
7984 118 tempitem.wpn4 = 0;
7985 118 tempitem.wpn5 = 0;
7986 118 tempitem.wpn6 = 0;
7987 118 tempitem.wpn7 = 0;
7988 118 tempitem.wpn8 = 0;
7989 118 tempitem.wpn9 = 0;
7990 118 tempitem.wpn10 = 0;
7991 118 break;
7992 }
7993 case itype_shield:
7994 {
7995 177 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7996 177 tempitem.misc3 = 0;
7997 177 tempitem.misc4 = 0;
7998 177 tempitem.misc5 = 0;
7999 177 tempitem.misc6 = 0;
8000 177 tempitem.misc7 = 0;
8001 177 tempitem.misc8 = 0;
8002 177 tempitem.misc9 = 0;
8003 177 tempitem.misc10 = 0;
8004 177 tempitem.wpn = 0;
8005 177 tempitem.wpn2 = 0;
8006 177 tempitem.wpn3 = 0;
8007 177 tempitem.wpn4 = 0;
8008 177 tempitem.wpn5 = 0;
8009 177 tempitem.wpn6 = 0;
8010 177 tempitem.wpn7 = 0;
8011 177 tempitem.wpn8 = 0;
8012 177 tempitem.wpn9 = 0;
8013 177 tempitem.wpn10 = 0;
8014 177 break;
8015 }
8016 case itype_bow:
8017 {
8018 118 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8019 118 tempitem.misc1 = 0;
8020 118 tempitem.misc2 = 0;
8021 118 tempitem.misc3 = 0;
8022 118 tempitem.misc4 = 0;
8023 118 tempitem.misc5 = 0;
8024 118 tempitem.misc6 = 0;
8025 118 tempitem.misc7 = 0;
8026 118 tempitem.misc8 = 0;
8027 118 tempitem.misc9 = 0;
8028 118 tempitem.misc10 = 0;
8029 118 tempitem.wpn = 0;
8030 118 tempitem.wpn2 = 0;
8031 118 tempitem.wpn3 = 0;
8032 118 tempitem.wpn4 = 0;
8033 118 tempitem.wpn5 = 0;
8034 118 tempitem.wpn6 = 0;
8035 118 tempitem.wpn7 = 0;
8036 118 tempitem.wpn8 = 0;
8037 118 tempitem.wpn9 = 0;
8038 118 tempitem.wpn10 = 0;
8039 118 break;
8040 }
8041 case itype_raft:
8042 {
8043 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8044 59 tempitem.misc1 = 0;
8045 59 tempitem.misc2 = 0;
8046 59 tempitem.misc3 = 0;
8047 59 tempitem.misc4 = 0;
8048 59 tempitem.misc5 = 0;
8049 59 tempitem.misc6 = 0;
8050 59 tempitem.misc7 = 0;
8051 59 tempitem.misc8 = 0;
8052 59 tempitem.misc9 = 0;
8053 59 tempitem.misc10 = 0;
8054 59 tempitem.wpn = 0;
8055 59 tempitem.wpn2 = 0;
8056 59 tempitem.wpn3 = 0;
8057 59 tempitem.wpn4 = 0;
8058 59 tempitem.wpn5 = 0;
8059 59 tempitem.wpn6 = 0;
8060 59 tempitem.wpn7 = 0;
8061 59 tempitem.wpn8 = 0;
8062 59 tempitem.wpn9 = 0;
8063 59 tempitem.wpn10 = 0;
8064 59 break;
8065 }
8066 case itype_ladder:
8067 {
8068 118 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8069 118 tempitem.misc1 = 0;
8070 118 tempitem.misc2 = 0;
8071 118 tempitem.misc3 = 0;
8072 118 tempitem.misc4 = 0;
8073 118 tempitem.misc5 = 0;
8074 118 tempitem.misc6 = 0;
8075 118 tempitem.misc7 = 0;
8076 118 tempitem.misc8 = 0;
8077 118 tempitem.misc9 = 0;
8078 118 tempitem.misc10 = 0;
8079 118 tempitem.wpn = 0;
8080 118 tempitem.wpn2 = 0;
8081 118 tempitem.wpn3 = 0;
8082 118 tempitem.wpn4 = 0;
8083 118 tempitem.wpn5 = 0;
8084 118 tempitem.wpn6 = 0;
8085 118 tempitem.wpn7 = 0;
8086 118 tempitem.wpn8 = 0;
8087 118 tempitem.wpn9 = 0;
8088 118 tempitem.wpn10 = 0;
8089 118 break;
8090 }
8091 case itype_book:
8092 {
8093 69 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8094 69 tempitem.misc1 = 0;
8095 69 tempitem.misc2 = 0;
8096 69 tempitem.misc3 = 0;
8097 69 tempitem.misc4 = 0;
8098 69 tempitem.misc5 = 0;
8099 69 tempitem.misc6 = 0;
8100 69 tempitem.misc7 = 0;
8101 69 tempitem.misc8 = 0;
8102 69 tempitem.misc9 = 0;
8103 69 tempitem.misc10 = 0;
8104 69 tempitem.wpn3 = 0;
8105 69 tempitem.wpn4 = 0;
8106 69 tempitem.wpn5 = 0;
8107 69 tempitem.wpn6 = 0;
8108 69 tempitem.wpn7 = 0;
8109 69 tempitem.wpn8 = 0;
8110 69 tempitem.wpn9 = 0;
8111 69 tempitem.wpn10 = 0;
8112 69 break;
8113 }
8114 case itype_magickey:
8115 {
8116 59 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8117 59 tempitem.misc1 = 0;
8118 59 tempitem.misc2 = 0;
8119 59 tempitem.misc3 = 0;
8120 59 tempitem.misc4 = 0;
8121 59 tempitem.misc5 = 0;
8122 59 tempitem.misc6 = 0;
8123 59 tempitem.misc7 = 0;
8124 59 tempitem.misc8 = 0;
8125 59 tempitem.misc9 = 0;
8126 59 tempitem.misc10 = 0;
8127 59 tempitem.wpn = 0;
8128 59 tempitem.wpn2 = 0;
8129 59 tempitem.wpn3 = 0;
8130 59 tempitem.wpn4 = 0;
8131 59 tempitem.wpn5 = 0;
8132 59 tempitem.wpn6 = 0;
8133 59 tempitem.wpn7 = 0;
8134 59 tempitem.wpn8 = 0;
8135 59 tempitem.wpn9 = 0;
8136 59 tempitem.wpn10 = 0;
8137 59 break;
8138 }
8139 case itype_bracelet:
8140 {
8141 177 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8142 177 tempitem.misc1 = 0;
8143 177 tempitem.misc2 = 0;
8144 177 tempitem.misc3 = 0;
8145 177 tempitem.misc4 = 0;
8146 177 tempitem.misc5 = 0;
8147 177 tempitem.misc6 = 0;
8148 177 tempitem.misc7 = 0;
8149 177 tempitem.misc8 = 0;
8150 177 tempitem.misc9 = 0;
8151 177 tempitem.misc10 = 0;
8152 177 tempitem.wpn = 0;
8153 177 tempitem.wpn2 = 0;
8154 177 tempitem.wpn3 = 0;
8155 177 tempitem.wpn4 = 0;
8156 177 tempitem.wpn5 = 0;
8157 177 tempitem.wpn6 = 0;
8158 177 tempitem.wpn7 = 0;
8159 177 tempitem.wpn8 = 0;
8160 177 tempitem.wpn9 = 0;
8161 177 tempitem.wpn10 = 0;
8162 177 break;
8163 }
8164 case itype_flippers:
8165 {
8166 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8167 59 tempitem.misc1 = 0;
8168 59 tempitem.misc2 = 0;
8169 59 tempitem.misc3 = 0;
8170 59 tempitem.misc4 = 0;
8171 59 tempitem.misc5 = 0;
8172 59 tempitem.misc6 = 0;
8173 59 tempitem.misc7 = 0;
8174 59 tempitem.misc8 = 0;
8175 59 tempitem.misc9 = 0;
8176 59 tempitem.misc10 = 0;
8177 59 tempitem.wpn = 0;
8178 59 tempitem.wpn2 = 0;
8179 59 tempitem.wpn3 = 0;
8180 59 tempitem.wpn4 = 0;
8181 59 tempitem.wpn5 = 0;
8182 59 tempitem.wpn6 = 0;
8183 59 tempitem.wpn7 = 0;
8184 59 tempitem.wpn8 = 0;
8185 59 tempitem.wpn9 = 0;
8186 59 tempitem.wpn10 = 0;
8187 59 break;
8188 }
8189 case itype_boots:
8190 {
8191 59 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8192 59 tempitem.misc1 = 0;
8193 59 tempitem.misc2 = 0;
8194 59 tempitem.misc3 = 0;
8195 59 tempitem.misc4 = 0;
8196 59 tempitem.misc5 = 0;
8197 59 tempitem.misc6 = 0;
8198 59 tempitem.misc7 = 0;
8199 59 tempitem.misc8 = 0;
8200 59 tempitem.misc9 = 0;
8201 59 tempitem.misc10 = 0;
8202 59 tempitem.wpn = 0;
8203 59 tempitem.wpn2 = 0;
8204 59 tempitem.wpn3 = 0;
8205 59 tempitem.wpn4 = 0;
8206 59 tempitem.wpn5 = 0;
8207 59 tempitem.wpn6 = 0;
8208 59 tempitem.wpn7 = 0;
8209 59 tempitem.wpn8 = 0;
8210 59 tempitem.wpn9 = 0;
8211 59 tempitem.wpn10 = 0;
8212 59 break;
8213 }
8214 case itype_hookshot:
8215 {
8216 118 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8217 118 tempitem.misc5 = 0;
8218 118 tempitem.misc6 = 0;
8219 118 tempitem.misc7 = 0;
8220 118 tempitem.misc8 = 0;
8221 118 tempitem.misc9 = 0;
8222 118 tempitem.misc10 = 0;
8223 118 tempitem.wpn5 = 0;
8224 118 tempitem.wpn6 = 0;
8225 118 tempitem.wpn7 = 0;
8226 118 tempitem.wpn8 = 0;
8227 118 tempitem.wpn9 = 0;
8228 118 tempitem.wpn10 = 0;
8229 118 break;
8230 }
8231 case itype_lens:
8232 {
8233 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8234 59 tempitem.misc2 = 0;
8235 59 tempitem.misc3 = 0;
8236 59 tempitem.misc4 = 0;
8237 59 tempitem.misc5 = 0;
8238 59 tempitem.misc6 = 0;
8239 59 tempitem.misc7 = 0;
8240 59 tempitem.misc8 = 0;
8241 59 tempitem.misc9 = 0;
8242 59 tempitem.misc10 = 0;
8243 59 tempitem.wpn = 0;
8244 59 tempitem.wpn2 = 0;
8245 59 tempitem.wpn3 = 0;
8246 59 tempitem.wpn4 = 0;
8247 59 tempitem.wpn5 = 0;
8248 59 tempitem.wpn6 = 0;
8249 59 tempitem.wpn7 = 0;
8250 59 tempitem.wpn8 = 0;
8251 59 tempitem.wpn9 = 0;
8252 59 tempitem.wpn10 = 0;
8253 59 break;
8254 }
8255 case itype_hammer:
8256 {
8257 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8258 59 tempitem.misc1 = 0;
8259 59 tempitem.misc2 = 0;
8260 59 tempitem.misc3 = 0;
8261 59 tempitem.misc4 = 0;
8262 59 tempitem.misc5 = 0;
8263 59 tempitem.misc6 = 0;
8264 59 tempitem.misc7 = 0;
8265 59 tempitem.misc8 = 0;
8266 59 tempitem.misc9 = 0;
8267 59 tempitem.misc10 = 0;
8268 59 tempitem.wpn3 = 0;
8269 59 tempitem.wpn4 = 0;
8270 59 tempitem.wpn5 = 0;
8271 59 tempitem.wpn6 = 0;
8272 59 tempitem.wpn7 = 0;
8273 59 tempitem.wpn8 = 0;
8274 59 tempitem.wpn9 = 0;
8275 59 tempitem.wpn10 = 0;
8276 59 break;
8277 }
8278 case itype_dinsfire:
8279 {
8280 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8281 59 tempitem.misc3 = 0;
8282 59 tempitem.misc4 = 0;
8283 59 tempitem.misc5 = 0;
8284 59 tempitem.misc6 = 0;
8285 59 tempitem.misc7 = 0;
8286 59 tempitem.misc8 = 0;
8287 59 tempitem.misc9 = 0;
8288 59 tempitem.misc10 = 0;
8289 59 tempitem.wpn6 = 0;
8290 59 tempitem.wpn7 = 0;
8291 59 tempitem.wpn8 = 0;
8292 59 tempitem.wpn9 = 0;
8293 59 tempitem.wpn10 = 0;
8294 59 break;
8295 }
8296 case itype_faroreswind:
8297 {
8298 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8299 59 tempitem.misc2 = 0;
8300 59 tempitem.misc3 = 0;
8301 59 tempitem.misc4 = 0;
8302 59 tempitem.misc5 = 0;
8303 59 tempitem.misc6 = 0;
8304 59 tempitem.misc7 = 0;
8305 59 tempitem.misc8 = 0;
8306 59 tempitem.misc9 = 0;
8307 59 tempitem.misc10 = 0;
8308 59 tempitem.wpn = 0;
8309 59 tempitem.wpn2 = 0;
8310 59 tempitem.wpn3 = 0;
8311 59 tempitem.wpn4 = 0;
8312 59 tempitem.wpn5 = 0;
8313 59 tempitem.wpn6 = 0;
8314 59 tempitem.wpn7 = 0;
8315 59 tempitem.wpn8 = 0;
8316 59 tempitem.wpn9 = 0;
8317 59 tempitem.wpn10 = 0;
8318 59 break;
8319 }
8320 case itype_nayruslove:
8321 {
8322 59 tempitem.flags &= ~ (ITEM_FLAG5);
8323 59 tempitem.misc2 = 0;
8324 59 tempitem.misc3 = 0;
8325 59 tempitem.misc4 = 0;
8326 59 tempitem.misc5 = 0;
8327 59 tempitem.misc6 = 0;
8328 59 tempitem.misc7 = 0;
8329 59 tempitem.misc8 = 0;
8330 59 tempitem.misc9 = 0;
8331 59 tempitem.misc10 = 0;
8332 59 break;
8333 }
8334 case itype_bomb:
8335 {
8336 69 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8337 69 tempitem.misc4 = 0;
8338 69 tempitem.misc5 = 0;
8339 69 tempitem.misc6 = 0;
8340 69 tempitem.misc7 = 0;
8341 69 tempitem.misc8 = 0;
8342 69 tempitem.misc9 = 0;
8343 69 tempitem.misc10 = 0;
8344 69 tempitem.wpn3 = 0;
8345 69 tempitem.wpn4 = 0;
8346 69 tempitem.wpn5 = 0;
8347 69 tempitem.wpn6 = 0;
8348 69 tempitem.wpn7 = 0;
8349 69 tempitem.wpn8 = 0;
8350 69 tempitem.wpn9 = 0;
8351 69 tempitem.wpn10 = 0;
8352 69 break;
8353 }
8354 case itype_sbomb:
8355 {
8356 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8357 59 tempitem.misc4 = 0;
8358 59 tempitem.misc5 = 0;
8359 59 tempitem.misc6 = 0;
8360 59 tempitem.misc7 = 0;
8361 59 tempitem.misc8 = 0;
8362 59 tempitem.misc9 = 0;
8363 59 tempitem.misc10 = 0;
8364 59 tempitem.wpn3 = 0;
8365 59 tempitem.wpn4 = 0;
8366 59 tempitem.wpn5 = 0;
8367 59 tempitem.wpn6 = 0;
8368 59 tempitem.wpn7 = 0;
8369 59 tempitem.wpn8 = 0;
8370 59 tempitem.wpn9 = 0;
8371 59 tempitem.wpn10 = 0;
8372 59 break;
8373 }
8374 case itype_clock:
8375 {
8376 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8377 59 tempitem.misc2 = 0;
8378 59 tempitem.misc3 = 0;
8379 59 tempitem.misc4 = 0;
8380 59 tempitem.misc5 = 0;
8381 59 tempitem.misc6 = 0;
8382 59 tempitem.misc7 = 0;
8383 59 tempitem.misc8 = 0;
8384 59 tempitem.misc9 = 0;
8385 59 tempitem.misc10 = 0;
8386 59 tempitem.wpn = 0;
8387 59 tempitem.wpn2 = 0;
8388 59 tempitem.wpn3 = 0;
8389 59 tempitem.wpn4 = 0;
8390 59 tempitem.wpn5 = 0;
8391 59 tempitem.wpn6 = 0;
8392 59 tempitem.wpn7 = 0;
8393 59 tempitem.wpn8 = 0;
8394 59 tempitem.wpn9 = 0;
8395 59 tempitem.wpn10 = 0;
8396 59 break;
8397 }
8398 case itype_key:
8399 {
8400 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8401 59 tempitem.misc1 = 0;
8402 59 tempitem.misc2 = 0;
8403 59 tempitem.misc3 = 0;
8404 59 tempitem.misc4 = 0;
8405 59 tempitem.misc5 = 0;
8406 59 tempitem.misc6 = 0;
8407 59 tempitem.misc7 = 0;
8408 59 tempitem.misc8 = 0;
8409 59 tempitem.misc9 = 0;
8410 59 tempitem.misc10 = 0;
8411 59 tempitem.wpn = 0;
8412 59 tempitem.wpn2 = 0;
8413 59 tempitem.wpn3 = 0;
8414 59 tempitem.wpn4 = 0;
8415 59 tempitem.wpn5 = 0;
8416 59 tempitem.wpn6 = 0;
8417 59 tempitem.wpn7 = 0;
8418 59 tempitem.wpn8 = 0;
8419 59 tempitem.wpn9 = 0;
8420 59 tempitem.wpn10 = 0;
8421 59 break;
8422 }
8423 case itype_magiccontainer:
8424 {
8425 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8426 59 tempitem.misc1 = 0;
8427 59 tempitem.misc2 = 0;
8428 59 tempitem.misc3 = 0;
8429 59 tempitem.misc4 = 0;
8430 59 tempitem.misc5 = 0;
8431 59 tempitem.misc6 = 0;
8432 59 tempitem.misc7 = 0;
8433 59 tempitem.misc8 = 0;
8434 59 tempitem.misc9 = 0;
8435 59 tempitem.misc10 = 0;
8436 59 tempitem.wpn = 0;
8437 59 tempitem.wpn2 = 0;
8438 59 tempitem.wpn3 = 0;
8439 59 tempitem.wpn4 = 0;
8440 59 tempitem.wpn5 = 0;
8441 59 tempitem.wpn6 = 0;
8442 59 tempitem.wpn7 = 0;
8443 59 tempitem.wpn8 = 0;
8444 59 tempitem.wpn9 = 0;
8445 59 tempitem.wpn10 = 0;
8446 59 break;
8447 }
8448 case itype_triforcepiece:
8449 {
8450 118 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8451 118 tempitem.misc3 = 0;
8452 118 tempitem.misc4 = 0;
8453 118 tempitem.misc5 = 0;
8454 118 tempitem.misc6 = 0;
8455 118 tempitem.misc7 = 0;
8456 118 tempitem.misc8 = 0;
8457 118 tempitem.misc9 = 0;
8458 118 tempitem.misc10 = 0;
8459 118 tempitem.wpn = 0;
8460 118 tempitem.wpn2 = 0;
8461 118 tempitem.wpn3 = 0;
8462 118 tempitem.wpn4 = 0;
8463 118 tempitem.wpn5 = 0;
8464 118 tempitem.wpn6 = 0;
8465 118 tempitem.wpn7 = 0;
8466 118 tempitem.wpn8 = 0;
8467 118 tempitem.wpn9 = 0;
8468 118 tempitem.wpn10 = 0;
8469 118 break;
8470 }
8471 case itype_map: case itype_compass: case itype_bosskey:
8472 {
8473 177 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8474 177 tempitem.misc1 = 0;
8475 177 tempitem.misc2 = 0;
8476 177 tempitem.misc3 = 0;
8477 177 tempitem.misc4 = 0;
8478 177 tempitem.misc5 = 0;
8479 177 tempitem.misc6 = 0;
8480 177 tempitem.misc7 = 0;
8481 177 tempitem.misc8 = 0;
8482 177 tempitem.misc9 = 0;
8483 177 tempitem.misc10 = 0;
8484 177 tempitem.wpn = 0;
8485 177 tempitem.wpn2 = 0;
8486 177 tempitem.wpn3 = 0;
8487 177 tempitem.wpn4 = 0;
8488 177 tempitem.wpn5 = 0;
8489 177 tempitem.wpn6 = 0;
8490 177 tempitem.wpn7 = 0;
8491 177 tempitem.wpn8 = 0;
8492 177 tempitem.wpn9 = 0;
8493 177 tempitem.wpn10 = 0;
8494 177 break;
8495 }
8496 case itype_quiver:
8497 {
8498 236 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8499 236 tempitem.misc3 = 0;
8500 236 tempitem.misc4 = 0;
8501 236 tempitem.misc5 = 0;
8502 236 tempitem.misc6 = 0;
8503 236 tempitem.misc7 = 0;
8504 236 tempitem.misc8 = 0;
8505 236 tempitem.misc9 = 0;
8506 236 tempitem.misc10 = 0;
8507 236 tempitem.wpn = 0;
8508 236 tempitem.wpn2 = 0;
8509 236 tempitem.wpn3 = 0;
8510 236 tempitem.wpn4 = 0;
8511 236 tempitem.wpn5 = 0;
8512 236 tempitem.wpn6 = 0;
8513 236 tempitem.wpn7 = 0;
8514 236 tempitem.wpn8 = 0;
8515 236 tempitem.wpn9 = 0;
8516 236 tempitem.wpn10 = 0;
8517 236 break;
8518 }
8519 case itype_lkey:
8520 {
8521 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8522 59 tempitem.misc1 = 0;
8523 59 tempitem.misc2 = 0;
8524 59 tempitem.misc3 = 0;
8525 59 tempitem.misc4 = 0;
8526 59 tempitem.misc5 = 0;
8527 59 tempitem.misc6 = 0;
8528 59 tempitem.misc7 = 0;
8529 59 tempitem.misc8 = 0;
8530 59 tempitem.misc9 = 0;
8531 59 tempitem.misc10 = 0;
8532 59 tempitem.wpn = 0;
8533 59 tempitem.wpn2 = 0;
8534 59 tempitem.wpn3 = 0;
8535 59 tempitem.wpn4 = 0;
8536 59 tempitem.wpn5 = 0;
8537 59 tempitem.wpn6 = 0;
8538 59 tempitem.wpn7 = 0;
8539 59 tempitem.wpn8 = 0;
8540 59 tempitem.wpn9 = 0;
8541 59 tempitem.wpn10 = 0;
8542 59 break;
8543 }
8544 case itype_cbyrna:
8545 {
8546 59 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8547 59 tempitem.misc4 = 0;
8548 59 tempitem.misc5 = 0;
8549 59 tempitem.misc6 = 0;
8550 59 tempitem.misc7 = 0;
8551 59 tempitem.misc8 = 0;
8552 59 tempitem.misc9 = 0;
8553 59 tempitem.misc10 = 0;
8554 59 tempitem.wpn6 = 0;
8555 59 tempitem.wpn7 = 0;
8556 59 tempitem.wpn8 = 0;
8557 59 tempitem.wpn9 = 0;
8558 59 tempitem.wpn10 = 0;
8559 59 break;
8560 }
8561 case itype_rupee: case itype_arrowammo:
8562 {
8563 761 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8564 761 tempitem.misc1 = 0;
8565 761 tempitem.misc2 = 0;
8566 761 tempitem.misc3 = 0;
8567 761 tempitem.misc4 = 0;
8568 761 tempitem.misc5 = 0;
8569 761 tempitem.misc6 = 0;
8570 761 tempitem.misc7 = 0;
8571 761 tempitem.misc8 = 0;
8572 761 tempitem.misc9 = 0;
8573 761 tempitem.misc10 = 0;
8574 761 tempitem.wpn = 0;
8575 761 tempitem.wpn2 = 0;
8576 761 tempitem.wpn3 = 0;
8577 761 tempitem.wpn4 = 0;
8578 761 tempitem.wpn5 = 0;
8579 761 tempitem.wpn6 = 0;
8580 761 tempitem.wpn7 = 0;
8581 761 tempitem.wpn8 = 0;
8582 761 tempitem.wpn9 = 0;
8583 761 tempitem.wpn10 = 0;
8584 761 break;
8585 }
8586 case itype_fairy:
8587 {
8588 105 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8589 105 tempitem.misc4 = 0;
8590 105 tempitem.misc5 = 0;
8591 105 tempitem.misc6 = 0;
8592 105 tempitem.misc7 = 0;
8593 105 tempitem.misc8 = 0;
8594 105 tempitem.misc9 = 0;
8595 105 tempitem.misc10 = 0;
8596 105 tempitem.wpn = 0;
8597 105 tempitem.wpn2 = 0;
8598 105 tempitem.wpn3 = 0;
8599 105 tempitem.wpn4 = 0;
8600 105 tempitem.wpn5 = 0;
8601 105 tempitem.wpn6 = 0;
8602 105 tempitem.wpn7 = 0;
8603 105 tempitem.wpn8 = 0;
8604 105 tempitem.wpn9 = 0;
8605 105 tempitem.wpn10 = 0;
8606 105 break;
8607 }
8608 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8609 {
8610 636 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8611 636 tempitem.misc1 = 0;
8612 636 tempitem.misc2 = 0;
8613 636 tempitem.misc3 = 0;
8614 636 tempitem.misc4 = 0;
8615 636 tempitem.misc5 = 0;
8616 636 tempitem.misc6 = 0;
8617 636 tempitem.misc7 = 0;
8618 636 tempitem.misc8 = 0;
8619 636 tempitem.misc9 = 0;
8620 636 tempitem.misc10 = 0;
8621 636 tempitem.wpn = 0;
8622 636 tempitem.wpn2 = 0;
8623 636 tempitem.wpn3 = 0;
8624 636 tempitem.wpn4 = 0;
8625 636 tempitem.wpn5 = 0;
8626 636 tempitem.wpn6 = 0;
8627 636 tempitem.wpn7 = 0;
8628 636 tempitem.wpn8 = 0;
8629 636 tempitem.wpn9 = 0;
8630 636 tempitem.wpn10 = 0;
8631 636 break;
8632 }
8633 case itype_bombbag:
8634 {
8635 236 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8636 236 tempitem.misc3 = 0;
8637 236 tempitem.misc4 = 0;
8638 236 tempitem.misc5 = 0;
8639 236 tempitem.misc6 = 0;
8640 236 tempitem.misc7 = 0;
8641 236 tempitem.misc8 = 0;
8642 236 tempitem.misc9 = 0;
8643 236 tempitem.misc10 = 0;
8644 236 tempitem.wpn = 0;
8645 236 tempitem.wpn2 = 0;
8646 236 tempitem.wpn3 = 0;
8647 236 tempitem.wpn4 = 0;
8648 236 tempitem.wpn5 = 0;
8649 236 tempitem.wpn6 = 0;
8650 236 tempitem.wpn7 = 0;
8651 236 tempitem.wpn8 = 0;
8652 236 tempitem.wpn9 = 0;
8653 236 tempitem.wpn10 = 0;
8654 236 break;
8655 }
8656 case itype_rocs:
8657 {
8658 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8659 59 tempitem.misc1 = 0;
8660 59 tempitem.misc2 = 0;
8661 59 tempitem.misc3 = 0;
8662 59 tempitem.misc4 = 0;
8663 59 tempitem.misc5 = 0;
8664 59 tempitem.misc6 = 0;
8665 59 tempitem.misc7 = 0;
8666 59 tempitem.misc8 = 0;
8667 59 tempitem.misc9 = 0;
8668 59 tempitem.misc10 = 0;
8669 59 tempitem.wpn = 0;
8670 59 tempitem.wpn2 = 0;
8671 59 tempitem.wpn3 = 0;
8672 59 tempitem.wpn4 = 0;
8673 59 tempitem.wpn5 = 0;
8674 59 tempitem.wpn6 = 0;
8675 59 tempitem.wpn7 = 0;
8676 59 tempitem.wpn8 = 0;
8677 59 tempitem.wpn9 = 0;
8678 59 tempitem.wpn10 = 0;
8679 59 break;
8680 }
8681 case itype_hoverboots:
8682 {
8683 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8684 59 tempitem.misc2 = 0;
8685 59 tempitem.misc3 = 0;
8686 59 tempitem.misc4 = 0;
8687 59 tempitem.misc5 = 0;
8688 59 tempitem.misc6 = 0;
8689 59 tempitem.misc7 = 0;
8690 59 tempitem.misc8 = 0;
8691 59 tempitem.misc9 = 0;
8692 59 tempitem.misc10 = 0;
8693 59 tempitem.wpn2 = 0;
8694 59 tempitem.wpn3 = 0;
8695 59 tempitem.wpn4 = 0;
8696 59 tempitem.wpn5 = 0;
8697 59 tempitem.wpn6 = 0;
8698 59 tempitem.wpn7 = 0;
8699 59 tempitem.wpn8 = 0;
8700 59 tempitem.wpn9 = 0;
8701 59 tempitem.wpn10 = 0;
8702 59 break;
8703 }
8704 case itype_spinscroll:
8705 {
8706 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8707 59 tempitem.misc2 = 0;
8708 59 tempitem.misc3 = 0;
8709 59 tempitem.misc4 = 0;
8710 59 tempitem.misc5 = 0;
8711 59 tempitem.misc6 = 0;
8712 59 tempitem.misc7 = 0;
8713 59 tempitem.misc8 = 0;
8714 59 tempitem.misc9 = 0;
8715 59 tempitem.misc10 = 0;
8716 59 tempitem.wpn = 0;
8717 59 tempitem.wpn2 = 0;
8718 59 tempitem.wpn3 = 0;
8719 59 tempitem.wpn4 = 0;
8720 59 tempitem.wpn5 = 0;
8721 59 tempitem.wpn6 = 0;
8722 59 tempitem.wpn7 = 0;
8723 59 tempitem.wpn8 = 0;
8724 59 tempitem.wpn9 = 0;
8725 59 tempitem.wpn10 = 0;
8726 59 break;
8727 }
8728 case itype_crossscroll:
8729 {
8730 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8731 59 tempitem.misc1 = 0;
8732 59 tempitem.misc2 = 0;
8733 59 tempitem.misc3 = 0;
8734 59 tempitem.misc4 = 0;
8735 59 tempitem.misc5 = 0;
8736 59 tempitem.misc6 = 0;
8737 59 tempitem.misc7 = 0;
8738 59 tempitem.misc8 = 0;
8739 59 tempitem.misc9 = 0;
8740 59 tempitem.misc10 = 0;
8741 59 tempitem.wpn = 0;
8742 59 tempitem.wpn2 = 0;
8743 59 tempitem.wpn3 = 0;
8744 59 tempitem.wpn4 = 0;
8745 59 tempitem.wpn5 = 0;
8746 59 tempitem.wpn6 = 0;
8747 59 tempitem.wpn7 = 0;
8748 59 tempitem.wpn8 = 0;
8749 59 tempitem.wpn9 = 0;
8750 59 tempitem.wpn10 = 0;
8751 59 break;
8752 }
8753 case itype_quakescroll:
8754 {
8755 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8756 59 tempitem.misc3 = 0;
8757 59 tempitem.misc4 = 0;
8758 59 tempitem.misc5 = 0;
8759 59 tempitem.misc6 = 0;
8760 59 tempitem.misc7 = 0;
8761 59 tempitem.misc8 = 0;
8762 59 tempitem.misc9 = 0;
8763 59 tempitem.misc10 = 0;
8764 59 tempitem.wpn = 0;
8765 59 tempitem.wpn2 = 0;
8766 59 tempitem.wpn3 = 0;
8767 59 tempitem.wpn4 = 0;
8768 59 tempitem.wpn5 = 0;
8769 59 tempitem.wpn6 = 0;
8770 59 tempitem.wpn7 = 0;
8771 59 tempitem.wpn8 = 0;
8772 59 tempitem.wpn9 = 0;
8773 59 tempitem.wpn10 = 0;
8774 59 break;
8775 }
8776 case itype_whispring:
8777 {
8778 118 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8779 118 tempitem.misc2 = 0;
8780 118 tempitem.misc3 = 0;
8781 118 tempitem.misc4 = 0;
8782 118 tempitem.misc5 = 0;
8783 118 tempitem.misc6 = 0;
8784 118 tempitem.misc7 = 0;
8785 118 tempitem.misc8 = 0;
8786 118 tempitem.misc9 = 0;
8787 118 tempitem.misc10 = 0;
8788 118 tempitem.wpn = 0;
8789 118 tempitem.wpn2 = 0;
8790 118 tempitem.wpn3 = 0;
8791 118 tempitem.wpn4 = 0;
8792 118 tempitem.wpn5 = 0;
8793 118 tempitem.wpn6 = 0;
8794 118 tempitem.wpn7 = 0;
8795 118 tempitem.wpn8 = 0;
8796 118 tempitem.wpn9 = 0;
8797 118 tempitem.wpn10 = 0;
8798 118 break;
8799 }
8800 case itype_chargering:
8801 {
8802 118 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8803 118 tempitem.misc3 = 0;
8804 118 tempitem.misc4 = 0;
8805 118 tempitem.misc5 = 0;
8806 118 tempitem.misc6 = 0;
8807 118 tempitem.misc7 = 0;
8808 118 tempitem.misc8 = 0;
8809 118 tempitem.misc9 = 0;
8810 118 tempitem.misc10 = 0;
8811 118 tempitem.wpn = 0;
8812 118 tempitem.wpn2 = 0;
8813 118 tempitem.wpn3 = 0;
8814 118 tempitem.wpn4 = 0;
8815 118 tempitem.wpn5 = 0;
8816 118 tempitem.wpn6 = 0;
8817 118 tempitem.wpn7 = 0;
8818 118 tempitem.wpn8 = 0;
8819 118 tempitem.wpn9 = 0;
8820 118 tempitem.wpn10 = 0;
8821 118 break;
8822 }
8823 case itype_perilscroll:
8824 {
8825 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8826 59 tempitem.misc2 = 0;
8827 59 tempitem.misc3 = 0;
8828 59 tempitem.misc4 = 0;
8829 59 tempitem.misc5 = 0;
8830 59 tempitem.misc6 = 0;
8831 59 tempitem.misc7 = 0;
8832 59 tempitem.misc8 = 0;
8833 59 tempitem.misc9 = 0;
8834 59 tempitem.misc10 = 0;
8835 59 tempitem.wpn = 0;
8836 59 tempitem.wpn2 = 0;
8837 59 tempitem.wpn3 = 0;
8838 59 tempitem.wpn4 = 0;
8839 59 tempitem.wpn5 = 0;
8840 59 tempitem.wpn6 = 0;
8841 59 tempitem.wpn7 = 0;
8842 59 tempitem.wpn8 = 0;
8843 59 tempitem.wpn9 = 0;
8844 59 tempitem.wpn10 = 0;
8845 59 break;
8846 }
8847 case itype_wealthmedal:
8848 {
8849 177 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8850 177 tempitem.misc2 = 0;
8851 177 tempitem.misc3 = 0;
8852 177 tempitem.misc4 = 0;
8853 177 tempitem.misc5 = 0;
8854 177 tempitem.misc6 = 0;
8855 177 tempitem.misc7 = 0;
8856 177 tempitem.misc8 = 0;
8857 177 tempitem.misc9 = 0;
8858 177 tempitem.misc10 = 0;
8859 177 tempitem.wpn = 0;
8860 177 tempitem.wpn2 = 0;
8861 177 tempitem.wpn3 = 0;
8862 177 tempitem.wpn4 = 0;
8863 177 tempitem.wpn5 = 0;
8864 177 tempitem.wpn6 = 0;
8865 177 tempitem.wpn7 = 0;
8866 177 tempitem.wpn8 = 0;
8867 177 tempitem.wpn9 = 0;
8868 177 tempitem.wpn10 = 0;
8869 177 break;
8870 }
8871 case itype_heartring:
8872 {
8873 177 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8874 177 tempitem.misc3 = 0;
8875 177 tempitem.misc4 = 0;
8876 177 tempitem.misc5 = 0;
8877 177 tempitem.misc6 = 0;
8878 177 tempitem.misc7 = 0;
8879 177 tempitem.misc8 = 0;
8880 177 tempitem.misc9 = 0;
8881 177 tempitem.misc10 = 0;
8882 177 tempitem.wpn = 0;
8883 177 tempitem.wpn2 = 0;
8884 177 tempitem.wpn3 = 0;
8885 177 tempitem.wpn4 = 0;
8886 177 tempitem.wpn5 = 0;
8887 177 tempitem.wpn6 = 0;
8888 177 tempitem.wpn7 = 0;
8889 177 tempitem.wpn8 = 0;
8890 177 tempitem.wpn9 = 0;
8891 177 tempitem.wpn10 = 0;
8892 177 break;
8893 }
8894 case itype_magicring:
8895 {
8896 236 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8897 236 tempitem.misc3 = 0;
8898 236 tempitem.misc4 = 0;
8899 236 tempitem.misc5 = 0;
8900 236 tempitem.misc6 = 0;
8901 236 tempitem.misc7 = 0;
8902 236 tempitem.misc8 = 0;
8903 236 tempitem.misc9 = 0;
8904 236 tempitem.misc10 = 0;
8905 236 tempitem.wpn = 0;
8906 236 tempitem.wpn2 = 0;
8907 236 tempitem.wpn3 = 0;
8908 236 tempitem.wpn4 = 0;
8909 236 tempitem.wpn5 = 0;
8910 236 tempitem.wpn6 = 0;
8911 236 tempitem.wpn7 = 0;
8912 236 tempitem.wpn8 = 0;
8913 236 tempitem.wpn9 = 0;
8914 236 tempitem.wpn10 = 0;
8915 236 break;
8916 }
8917 case itype_spinscroll2:
8918 {
8919 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8920 59 tempitem.misc2 = 0;
8921 59 tempitem.misc3 = 0;
8922 59 tempitem.misc4 = 0;
8923 59 tempitem.misc5 = 0;
8924 59 tempitem.misc6 = 0;
8925 59 tempitem.misc7 = 0;
8926 59 tempitem.misc8 = 0;
8927 59 tempitem.misc9 = 0;
8928 59 tempitem.misc10 = 0;
8929 59 tempitem.wpn = 0;
8930 59 tempitem.wpn2 = 0;
8931 59 tempitem.wpn3 = 0;
8932 59 tempitem.wpn4 = 0;
8933 59 tempitem.wpn5 = 0;
8934 59 tempitem.wpn6 = 0;
8935 59 tempitem.wpn7 = 0;
8936 59 tempitem.wpn8 = 0;
8937 59 tempitem.wpn9 = 0;
8938 59 tempitem.wpn10 = 0;
8939 59 break;
8940 }
8941 case itype_quakescroll2:
8942 {
8943 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8944 59 tempitem.misc3 = 0;
8945 59 tempitem.misc4 = 0;
8946 59 tempitem.misc5 = 0;
8947 59 tempitem.misc6 = 0;
8948 59 tempitem.misc7 = 0;
8949 59 tempitem.misc8 = 0;
8950 59 tempitem.misc9 = 0;
8951 59 tempitem.misc10 = 0;
8952 59 tempitem.wpn = 0;
8953 59 tempitem.wpn2 = 0;
8954 59 tempitem.wpn3 = 0;
8955 59 tempitem.wpn4 = 0;
8956 59 tempitem.wpn5 = 0;
8957 59 tempitem.wpn6 = 0;
8958 59 tempitem.wpn7 = 0;
8959 59 tempitem.wpn8 = 0;
8960 59 tempitem.wpn9 = 0;
8961 59 tempitem.wpn10 = 0;
8962 59 break;
8963 }
8964 case itype_agony:
8965 {
8966 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8967 59 tempitem.misc2 = 0;
8968 59 tempitem.misc3 = 0;
8969 59 tempitem.misc4 = 0;
8970 59 tempitem.misc5 = 0;
8971 59 tempitem.misc6 = 0;
8972 59 tempitem.misc7 = 0;
8973 59 tempitem.misc8 = 0;
8974 59 tempitem.misc9 = 0;
8975 59 tempitem.misc10 = 0;
8976 59 tempitem.wpn = 0;
8977 59 tempitem.wpn2 = 0;
8978 59 tempitem.wpn3 = 0;
8979 59 tempitem.wpn4 = 0;
8980 59 tempitem.wpn5 = 0;
8981 59 tempitem.wpn6 = 0;
8982 59 tempitem.wpn7 = 0;
8983 59 tempitem.wpn8 = 0;
8984 59 tempitem.wpn9 = 0;
8985 59 tempitem.wpn10 = 0;
8986 59 break;
8987 }
8988 case itype_stompboots:
8989 {
8990 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8991 59 tempitem.misc1 = 0;
8992 59 tempitem.misc2 = 0;
8993 59 tempitem.misc3 = 0;
8994 59 tempitem.misc4 = 0;
8995 59 tempitem.misc5 = 0;
8996 59 tempitem.misc6 = 0;
8997 59 tempitem.misc7 = 0;
8998 59 tempitem.misc8 = 0;
8999 59 tempitem.misc9 = 0;
9000 59 tempitem.misc10 = 0;
9001 59 tempitem.wpn = 0;
9002 59 tempitem.wpn2 = 0;
9003 59 tempitem.wpn3 = 0;
9004 59 tempitem.wpn4 = 0;
9005 59 tempitem.wpn5 = 0;
9006 59 tempitem.wpn6 = 0;
9007 59 tempitem.wpn7 = 0;
9008 59 tempitem.wpn8 = 0;
9009 59 tempitem.wpn9 = 0;
9010 59 tempitem.wpn10 = 0;
9011 59 break;
9012 }
9013 case itype_whimsicalring:
9014 {
9015 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9016 59 tempitem.misc2 = 0;
9017 59 tempitem.misc3 = 0;
9018 59 tempitem.misc4 = 0;
9019 59 tempitem.misc5 = 0;
9020 59 tempitem.misc6 = 0;
9021 59 tempitem.misc7 = 0;
9022 59 tempitem.misc8 = 0;
9023 59 tempitem.misc9 = 0;
9024 59 tempitem.misc10 = 0;
9025 59 tempitem.wpn = 0;
9026 59 tempitem.wpn2 = 0;
9027 59 tempitem.wpn3 = 0;
9028 59 tempitem.wpn4 = 0;
9029 59 tempitem.wpn5 = 0;
9030 59 tempitem.wpn6 = 0;
9031 59 tempitem.wpn7 = 0;
9032 59 tempitem.wpn8 = 0;
9033 59 tempitem.wpn9 = 0;
9034 59 tempitem.wpn10 = 0;
9035 59 break;
9036 }
9037 case itype_perilring:
9038 {
9039 59 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9040 59 tempitem.misc2 = 0;
9041 59 tempitem.misc3 = 0;
9042 59 tempitem.misc4 = 0;
9043 59 tempitem.misc5 = 0;
9044 59 tempitem.misc6 = 0;
9045 59 tempitem.misc7 = 0;
9046 59 tempitem.misc8 = 0;
9047 59 tempitem.misc9 = 0;
9048 59 tempitem.misc10 = 0;
9049 59 tempitem.wpn = 0;
9050 59 tempitem.wpn2 = 0;
9051 59 tempitem.wpn3 = 0;
9052 59 tempitem.wpn4 = 0;
9053 59 tempitem.wpn5 = 0;
9054 59 tempitem.wpn6 = 0;
9055 59 tempitem.wpn7 = 0;
9056 59 tempitem.wpn8 = 0;
9057 59 tempitem.wpn9 = 0;
9058 59 tempitem.wpn10 = 0;
9059 59 break;
9060 }
9061 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9062 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9063 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9064 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9065 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9066 {
9067 1359 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9068 1359 tempitem.misc1 = 0;
9069 1359 tempitem.misc2 = 0;
9070 1359 tempitem.misc3 = 0;
9071 1359 tempitem.misc4 = 0;
9072 1359 tempitem.misc5 = 0;
9073 1359 tempitem.misc6 = 0;
9074 1359 tempitem.misc7 = 0;
9075 1359 tempitem.misc8 = 0;
9076 1359 tempitem.misc9 = 0;
9077 1359 tempitem.misc10 = 0;
9078 1359 tempitem.wpn = 0;
9079 1359 tempitem.wpn2 = 0;
9080 1359 tempitem.wpn3 = 0;
9081 1359 tempitem.wpn4 = 0;
9082 1359 tempitem.wpn5 = 0;
9083 1359 tempitem.wpn6 = 0;
9084 1359 tempitem.wpn7 = 0;
9085 1359 tempitem.wpn8 = 0;
9086 1359 tempitem.wpn9 = 0;
9087 1359 tempitem.wpn10 = 0;
9088 1359 break;
9089 }
9090 }
9091 15104 }
9092 //Port quest rules to items
9093
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if( s_version <= 31)
9094 {
9095
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 15035 times.
15104 if(tempitem.family == itype_bomb)
9096 {
9097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9098 69 else tempitem.flags &= ~ ITEM_FLAG2;
9099 69 }
9100
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 14976 times.
15035 else if(tempitem.family == itype_sbomb)
9101 {
9102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9103 59 else tempitem.flags &= ~ ITEM_FLAG2;
9104 59 }
9105
9106
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 14799 times.
14976 else if(tempitem.family == itype_brang)
9107 {
9108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
177 if ( get_bit(quest_rules,qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9109 177 else tempitem.flags &= ~ ITEM_FLAG4;
9110 177 }
9111
2/2
✓ Branch 0 taken 14730 times.
✓ Branch 1 taken 69 times.
14799 else if(tempitem.family == itype_wand)
9112 {
9113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if ( get_bit(quest_rules,qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9114 69 else tempitem.flags &= ~ ITEM_FLAG3;
9115 69 }
9116 15104 }
9117
9118 //Port quest rules to items
9119
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if( s_version <= 37)
9120 {
9121
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 15045 times.
15104 if(tempitem.family == itype_flippers)
9122 {
9123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if ( (get_bit(quest_rules,qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9124 59 else tempitem.flags &= ~ ITEM_FLAG1;
9125 59 }
9126
2/2
✓ Branch 0 taken 9905 times.
✓ Branch 1 taken 5140 times.
15045 else if(tempitem.family == itype_sword)
9127 {
9128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5140 times.
5140 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9129 5140 else tempitem.flags &= ~ ITEM_FLAG5;
9130 5140 }
9131
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 9836 times.
9905 else if(tempitem.family == itype_wand)
9132 {
9133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9134 69 else tempitem.flags &= ~ ITEM_FLAG5;
9135 69 }
9136
4/4
✓ Branch 0 taken 9767 times.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 151 times.
✓ Branch 3 taken 9616 times.
9836 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9137 {
9138 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9139
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 181 times.
220 if ( (get_bit(quest_rules,qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9140 181 else tempitem.flags &= ~ ITEM_FLAG3;
9141 220 }
9142 15104 }
9143
9144
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if( s_version < 38)
9145 {
9146
4/4
✓ Branch 0 taken 14927 times.
✓ Branch 1 taken 177 times.
✓ Branch 2 taken 118 times.
✓ Branch 3 taken 14809 times.
15104 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9147 {
9148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 295 times.
295 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9149 295 else tempitem.flags &= ~ITEM_FLAG4;
9150
9151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 295 times.
295 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9152 295 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9153 295 }
9154
2/2
✓ Branch 0 taken 14632 times.
✓ Branch 1 taken 177 times.
14809 else if(tempitem.family == itype_arrow)
9155 {
9156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
177 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9157 177 else tempitem.flags &= ~ITEM_FLAG4;
9158
9159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
177 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9160 177 else tempitem.flags |= ITEM_FLAG2;
9161 177 }
9162 15104 }
9163
9164
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if( s_version < 39)
9165 {
9166
6/6
✓ Branch 0 taken 15045 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 14976 times.
✓ Branch 3 taken 69 times.
✓ Branch 4 taken 151 times.
✓ Branch 5 taken 14825 times.
15104 if(tempitem.family == itype_dinsfire || tempitem.family == itype_book || tempitem.family == itype_candle)
9167 {
9168
1/2
✓ Branch 0 taken 279 times.
✗ Branch 1 not taken.
279 if(get_bit(quest_rules,qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9169 279 else tempitem.flags &= ~ITEM_FLAG5;
9170 279 }
9171
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 14707 times.
14825 else if(tempitem.family == itype_potion)
9172 {
9173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if(get_bit(quest_rules,qr_NONBUBBLEMEDICINE))
9174 {
9175 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9176 }
9177 else
9178 {
9179 118 tempitem.flags |= ITEM_FLAG3;
9180
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 46 times.
118 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9181 46 else tempitem.flags &= ~ITEM_FLAG4;
9182 }
9183 118 }
9184
2/2
✓ Branch 0 taken 14589 times.
✓ Branch 1 taken 118 times.
14707 else if(tempitem.family == itype_triforcepiece)
9185 {
9186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if(get_bit(quest_rules,qr_NONBUBBLETRIFORCE))
9187 {
9188 tempitem.flags |= ITEM_FLAG3;
9189 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9190 else tempitem.flags &= ~ITEM_FLAG4;
9191 }
9192 else
9193 {
9194 118 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9195 }
9196 118 }
9197 15104 }
9198
9199
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if( s_version < 40)
9200 {
9201
4/4
✓ Branch 0 taken 14927 times.
✓ Branch 1 taken 177 times.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 14868 times.
15104 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9202 {
9203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236 times.
236 if(get_bit(quest_rules,qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9204 236 else tempitem.flags &= ~ITEM_FLAG1;
9205 236 }
9206
8/8
✓ Branch 0 taken 14717 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 9577 times.
✓ Branch 3 taken 5140 times.
✓ Branch 4 taken 9508 times.
✓ Branch 5 taken 69 times.
✓ Branch 6 taken 59 times.
✓ Branch 7 taken 9449 times.
14868 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9207 {
9208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5419 times.
5419 if(get_bit(quest_rules,qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9209 5419 else tempitem.flags &= ~ITEM_FLAG8;
9210 5419 }
9211
6/6
✓ Branch 0 taken 9964 times.
✓ Branch 1 taken 5140 times.
✓ Branch 2 taken 9895 times.
✓ Branch 3 taken 69 times.
✓ Branch 4 taken 59 times.
✓ Branch 5 taken 9836 times.
15104 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9212 {
9213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5268 times.
5268 if(get_bit(quest_rules,qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9214 5268 else tempitem.flags &= ~ITEM_FLAG7;
9215 5268 }
9216
2/2
✓ Branch 0 taken 9777 times.
✓ Branch 1 taken 59 times.
9836 else if(tempitem.family == itype_cbyrna)
9217 {
9218 59 tempitem.flags |= ITEM_FLAG7;
9219 59 }
9220 15104 }
9221
9222
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if( s_version < 41 )
9223 {
9224
2/2
✓ Branch 0 taken 9964 times.
✓ Branch 1 taken 5140 times.
15104 if(tempitem.family == itype_sword)
9225 {
9226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5140 times.
5140 if(get_bit(quest_rules,qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9227 5140 else tempitem.flags &= ~ITEM_FLAG9;
9228
9229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5140 times.
5140 if(get_bit(quest_rules,qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9230 5140 else tempitem.flags &= ~ITEM_FLAG10;
9231 5140 }
9232 15104 }
9233
9234
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if( s_version < 42 )
9235 {
9236
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 15035 times.
15104 if(tempitem.family == itype_wand)
9237 {
9238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(get_bit(quest_rules,qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9239 69 else tempitem.flags &= ~ITEM_FLAG3;
9240
9241 69 tempitem.flags &= ~ITEM_FLAG6;
9242 69 }
9243
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 14976 times.
15035 else if(tempitem.family == itype_hammer)
9244 {
9245 59 tempitem.flags &= ~ITEM_FLAG3;
9246 59 }
9247
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 14917 times.
14976 else if(tempitem.family == itype_cbyrna)
9248 {
9249 59 tempitem.flags |= ITEM_FLAG3;
9250
9251 59 tempitem.flags &= ~ITEM_FLAG6;
9252 59 }
9253
2/2
✓ Branch 0 taken 9777 times.
✓ Branch 1 taken 5140 times.
14917 else if(tempitem.family == itype_sword)
9254 {
9255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5140 times.
5140 if(get_bit(quest_rules,qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9256 5140 else tempitem.flags &= ~ITEM_FLAG6;
9257 5140 }
9258 15104 }
9259
9260
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if( s_version < 43 )
9261 {
9262
2/2
✓ Branch 0 taken 14999 times.
✓ Branch 1 taken 105 times.
15104 if(tempitem.family == itype_whistle)
9263 {
9264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(get_bit(quest_rules,qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9265 105 else tempitem.flags &= ~ITEM_FLAG3;
9266 105 }
9267 15104 }
9268
9269
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if( s_version < 45 )
9270 {
9271
2/2
✓ Branch 0 taken 15045 times.
✓ Branch 1 taken 59 times.
15104 if(tempitem.family == itype_flippers)
9272 {
9273 59 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9274 59 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9275 59 }
9276 15104 }
9277
9278
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if( s_version < 46 )
9279 {
9280
2/2
✓ Branch 0 taken 15045 times.
✓ Branch 1 taken 59 times.
15104 if(tempitem.family == itype_raft)
9281 {
9282 59 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9283 59 }
9284 15104 }
9285
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if ( s_version < 34 ) //! set the default counter for older quests.
9286 {
9287
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 15045 times.
15104 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9288 {
9289 59 tempitem.cost_counter[0] = 1;
9290 59 }
9291 else
9292 {
9293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15045 times.
15045 if(get_bit(quest_rules,qr_ENABLEMAGIC))
9294 tempitem.cost_counter[0] = 4;
9295 else
9296 {
9297 15045 tempitem.cost_amount[0] = 0;
9298 15045 tempitem.cost_counter[0] = -1;
9299 }
9300 }
9301 15104 }
9302
9303
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if ( s_version < 35 ) //new Lens of Truth flags
9304 {
9305
2/2
✓ Branch 0 taken 15045 times.
✓ Branch 1 taken 59 times.
15104 if ( tempitem.family == itype_lens )
9306 {
9307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if ( get_bit(quest_rules,qr_RAFTLENS) )
9308 {
9309 tempitem.flags |= ITEM_FLAG4;
9310 }
9311
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 36 times.
59 if ( get_bit(quest_rules,qr_LENSHINTS) )
9312 {
9313 23 tempitem.flags |= ITEM_FLAG1;
9314 23 }
9315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if ( get_bit(quest_rules,qr_LENSSEESENEMIES) )
9316 {
9317 tempitem.flags |= ITEM_FLAG5;
9318 }
9319 59 }
9320 15104 }
9321
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9322 {
9323
2/2
✓ Branch 0 taken 120832 times.
✓ Branch 1 taken 15104 times.
135936 for ( int32_t q = 0; q < 8; q++ )
9324 {
9325 120832 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9326 120832 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9327 120832 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9328 120832 tempitem.sprite_initiald[q] = 0;
9329 120832 }
9330
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 15104 times.
45312 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9331 15104 tempitem.sprite_script = 0;
9332 15104 }
9333
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9334 {
9335 15104 tempitem.pickupflag = 0;
9336 15104 }
9337
9338
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if( s_version < 51 )
9339 {
9340
2/2
✓ Branch 0 taken 14953 times.
✓ Branch 1 taken 151 times.
15104 if( tempitem.family == itype_candle )
9341 {
9342 151 tempitem.misc4 = 50; //Step speed
9343 151 }
9344 15104 }
9345
9346
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if( s_version < 52 )
9347 {
9348
2/2
✓ Branch 0 taken 14927 times.
✓ Branch 1 taken 177 times.
15104 if( tempitem.family == itype_shield )
9349 177 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9350 15104 }
9351
9352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
15872 if(tempitem.fam_type==0) // Always do this
9353 tempitem.fam_type=1;
9354
9355 15872 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9356 15872 }
9357 62 }
9358
9359 62 return 0;
9360 62 }
9361
9362 static bool did_init_def_items = false;
9363 31744 void init_def_items()
9364 {
9365
2/2
✓ Branch 0 taken 31733 times.
✓ Branch 1 taken 11 times.
31744 if(did_init_def_items) return;
9366 11 did_init_def_items = true;
9367 11 default_items[3].cost_counter[1] = crBOMBS;
9368 11 default_items[13].cost_counter[1] = crARROWS;
9369 11 default_items[14].cost_counter[1] = crARROWS;
9370 11 default_items[48].cost_counter[1] = crBOMBS;
9371 11 default_items[57].cost_counter[1] = crARROWS;
9372 31744 }
9373 31744 void reset_itembuf(itemdata *item, int32_t id)
9374 {
9375 31744 init_def_items();
9376
2/2
✓ Branch 0 taken 14012 times.
✓ Branch 1 taken 17732 times.
31744 if(id<iLast)
9377 {
9378 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9379 17732 word tile = item->tile;
9380 17732 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9381 17732 int32_t ltm = item->ltm;
9382
9383 17732 memcpy(item,&default_items[id],sizeof(itemdata));
9384 17732 item->tile = tile;
9385 17732 item->misc_flags = miscs;
9386 17732 item->csets = cset;
9387 17732 item->frames = frames;
9388 17732 item->speed = speed;
9389 17732 item->delay = delay;
9390 17732 item->ltm = ltm;
9391 17732 }
9392 31744 }
9393
9394 2816 void reset_itemname(int32_t id)
9395 {
9396 2816 sprintf(item_string[id],"zz%03d",id);
9397
9398
2/2
✓ Branch 0 taken 1243 times.
✓ Branch 1 taken 1573 times.
2816 if(id < iLast)
9399 1573 strcpy(item_string[id],old_item_string[id]);
9400 2816 }
9401
9402 62 int32_t readweapons(PACKFILE *f, zquestheader *Header, bool keepdata)
9403 {
9404 62 word weapons_to_read=MAXWPNS;
9405 int32_t dummy;
9406 byte padding;
9407 wpndata tempweapon;
9408 62 word s_version=0, s_cversion=0;
9409
9410
9411
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(Header->zelda_version < 0x186)
9412 {
9413 weapons_to_read=64;
9414 }
9415
9416
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(Header->zelda_version < 0x185)
9417 {
9418 weapons_to_read=32;
9419 }
9420
9421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(Header->zelda_version > 0x192)
9422 {
9423 62 weapons_to_read=0;
9424
9425 //section version info
9426
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_version,f,true))
9427 {
9428 return qe_invalid;
9429 }
9430
9431 62 FFCore.quest_format[vWeaponSprites] = s_version;
9432
9433 //al_trace("Weapons version %d\n", s_version);
9434
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_cversion,f,true))
9435 {
9436 return qe_invalid;
9437 }
9438
9439 //section size
9440
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&dummy,f,true))
9441 {
9442 return qe_invalid;
9443 }
9444
9445 //finally... section data
9446
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&weapons_to_read,f,true))
9447 {
9448 return qe_invalid;
9449 }
9450 62 }
9451
9452
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version>2)
9453 {
9454
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<weapons_to_read; i++)
9455 {
9456 char tempname[64];
9457
9458
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!pfread(tempname, 64, f, keepdata))
9459 {
9460 return qe_invalid;
9461 }
9462
9463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
15872 if(keepdata)
9464 {
9465 15872 strcpy(weapon_string[i], tempname);
9466 15872 }
9467 15872 }
9468
9469
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version<4)
9470 {
9471 if(keepdata)
9472 {
9473 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9474 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9475 }
9476 }
9477
9478
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version<5)
9479 {
9480 if(keepdata)
9481 {
9482 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9483 }
9484 }
9485
9486 /*
9487 if (s_version<6)
9488 {
9489 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9490 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9491 }
9492 */
9493 62 }
9494 else
9495 {
9496 if(keepdata)
9497 for(int32_t i=0; i<WPNCNT; i++)
9498 reset_weaponname(i);
9499 }
9500
9501
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<weapons_to_read; i++)
9502 {
9503 15872 word oldtile = 0;
9504
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 15360 times.
15872 if (s_version < 8)
9505 {
9506
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if (!p_igetw(&oldtile, f, true))
9507 return qe_invalid;
9508 15360 }
9509
9510
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempweapon.misc,f,true))
9511 {
9512 return qe_invalid;
9513 }
9514
9515
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempweapon.csets,f,true))
9516 {
9517 return qe_invalid;
9518 }
9519
9520
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempweapon.frames,f,true))
9521 {
9522 return qe_invalid;
9523 }
9524
9525
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempweapon.speed,f,true))
9526 {
9527 return qe_invalid;
9528 }
9529
9530
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(!p_getc(&tempweapon.type,f,true))
9531 {
9532 return qe_invalid;
9533 }
9534
9535
2/2
✓ Branch 0 taken 15104 times.
✓ Branch 1 taken 768 times.
15872 if ( s_version >= 7 )
9536 {
9537
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetw(&tempweapon.script,f,true))
9538 {
9539 return qe_invalid;
9540 }
9541
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tempweapon.tile,f,true))
9542 {
9543 return qe_invalid;
9544 }
9545 768 }
9546
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 15104 times.
15872 if ( s_version < 7 )
9547 {
9548 15104 tempweapon.tile = oldtile;
9549 15104 }
9550
9551
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(Header->zelda_version < 0x193)
9552 {
9553 if(!p_getc(&padding,f,true))
9554 {
9555 return qe_invalid;
9556 }
9557 }
9558
9559
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(s_version < 6)
9560 {
9561 if(i==ewFIRETRAIL)
9562 {
9563 tempweapon.misc |= WF_BEHIND;
9564 }
9565 else
9566 tempweapon.misc &= ~WF_BEHIND;
9567 }
9568
9569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
15872 if(keepdata==true)
9570 {
9571 15872 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9572 15872 }
9573 15872 }
9574
9575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata==true)
9576 {
9577
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version<2)
9578 {
9579 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9580 }
9581
9582
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version<5)
9583 {
9584 wpnsbuf[iwQuarterHearts].tile=1;
9585 wpnsbuf[iwQuarterHearts].csets=1;
9586 }
9587
9588
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(Header->zelda_version < 0x176)
9589 {
9590 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9591 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9592 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9593 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9594 }
9595
9596
1/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 if((Header->zelda_version < 0x192)||
9597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9598 {
9599 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9600 }
9601
9602
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if((Header->zelda_version < 0x210))
9603 {
9604 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9605 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9606 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9607 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9608 }
9609 62 }
9610
9611 62 return 0;
9612 62 }
9613
9614 62 void init_guys(int32_t guyversion)
9615 {
9616
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 62 times.
31806 for(int32_t i=0; i<MAXGUYS; i++)
9617 {
9618 31744 guysbuf[i] = default_guys[0];
9619 31744 }
9620
9621
2/2
✓ Branch 0 taken 10974 times.
✓ Branch 1 taken 62 times.
11036 for(int32_t i=0; i<OLDMAXGUYS; i++)
9622 {
9623 10974 guysbuf[i] = default_guys[i];
9624
2/2
✓ Branch 0 taken 10850 times.
✓ Branch 1 taken 124 times.
10974 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9625 10974 guysbuf[i].spr_death = iwDeath;
9626 10974 guysbuf[i].spr_spawn = iwSpawn;
9627 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9628
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10974 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10974 if(guyversion<=3 && i==ePATRABS)
9629 {
9630 guysbuf[i].bosspal=spDIG;
9631 guysbuf[i].cset=14;
9632 guysbuf[i].misc9=14;
9633 }
9634
9635
1/2
✓ Branch 0 taken 10974 times.
✗ Branch 1 not taken.
10974 if(guyversion<=3)
9636 {
9637 // Rope/Ghini Flash rules
9638 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9639 {
9640 if(i==eROPE2)
9641 {
9642 guysbuf[i].flags2 &= ~guy_flashing;
9643 }
9644 }
9645
9646 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9647 {
9648 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9649 {
9650 guysbuf[i].flags2 &= ~guy_flashing;
9651 }
9652 }
9653
9654 if(i==eGHINI2)
9655 {
9656 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9657 {
9658 guysbuf[i].flags2 |= guy_blinking;
9659 }
9660
9661 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9662 {
9663 guysbuf[i].flags2 |= guy_transparent;
9664 }
9665 }
9666 }
9667
9668 // Darknut fix
9669
10/10
✓ Branch 0 taken 10912 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 10850 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 10788 times.
✓ Branch 5 taken 62 times.
✓ Branch 6 taken 10726 times.
✓ Branch 7 taken 62 times.
✓ Branch 8 taken 62 times.
✓ Branch 9 taken 10664 times.
10974 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9670 {
9671
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 180 times.
310 if(get_bit(quest_rules,qr_NEWENEMYTILES))
9672 {
9673 130 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9674 130 guysbuf[i].s_width=guysbuf[i].e_width;
9675 130 guysbuf[i].s_height=guysbuf[i].e_height;
9676 130 }
9677 180 else guysbuf[i].s_tile=860;
9678
9679
1/2
✓ Branch 0 taken 310 times.
✗ Branch 1 not taken.
310 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9680 {
9681 guysbuf[i].flags |= guy_bkshield;
9682 }
9683 310 }
9684
9685
3/4
✓ Branch 0 taken 10912 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 10974 times.
✗ Branch 3 not taken.
10974 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9686 {
9687 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9688 }
9689 10974 }
9690 62 }
9691
9692 void reset_weaponname(int32_t i)
9693 {
9694 if(i<wLast)
9695 {
9696 strcpy(weapon_string[i],old_weapon_string[i]);
9697 }
9698 else
9699 sprintf(weapon_string[i],"zz%03d",i);
9700 }
9701
9702 62 void init_item_drop_sets()
9703 {
9704
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9705 {
9706 // item_drop_sets[i] = default_item_drop_sets[0];
9707 15872 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9708 15872 }
9709
9710
2/2
✓ Branch 0 taken 806 times.
✓ Branch 1 taken 62 times.
868 for(int32_t i=0; i<isMAX; i++)
9711 {
9712 806 item_drop_sets[i] = default_item_drop_sets[i];
9713
9714 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9715
2/2
✓ Branch 0 taken 8060 times.
✓ Branch 1 taken 806 times.
8866 for(int32_t j=0; j<10; ++j)
9716 {
9717 8060 int32_t it = item_drop_sets[i].item[j];
9718
9719
3/4
✓ Branch 0 taken 5704 times.
✓ Branch 1 taken 2356 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 372 times.
8060 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9720
2/2
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 5332 times.
5704 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9721 {
9722 372 item_drop_sets[i].chance[j+1]=0;
9723 372 }
9724
3/4
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 7440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 248 times.
7688 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9725 {
9726 item_drop_sets[i].chance[j+1]=0;
9727 }
9728
9729 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9730
1/2
✓ Branch 0 taken 8060 times.
✗ Branch 1 not taken.
8060 if(itemsbuf[it].family == itype_misc)
9731 {
9732 // If a non-gameplay item was selected, then item drop was aborted.
9733 // Reflect this by increasing the 'Nothing' chance accordingly.
9734 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9735 item_drop_sets[i].chance[j+1]=0;
9736 }
9737 8060 }
9738 806 }
9739 62 }
9740
9741 62 void init_favorites()
9742 {
9743
2/2
✓ Branch 0 taken 6200 times.
✓ Branch 1 taken 62 times.
6262 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9744 {
9745 6200 favorite_combos[i]=-1;
9746 6200 }
9747
9748
2/2
✓ Branch 0 taken 6200 times.
✓ Branch 1 taken 62 times.
6262 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9749 {
9750 6200 favorite_comboaliases[i]=-1;
9751 6200 }
9752 62 }
9753
9754 const char *ctype_name[cMAX]=
9755 {
9756 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9757 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9758 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9759 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9760 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9761 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9762 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9763 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9764 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9765 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9766 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9767 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9768 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9769 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9770 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9771 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9772 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9773 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9774 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9775 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9776 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9777 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9778 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9779 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9780 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9781 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9782 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9783 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9784
9785 };
9786
9787 121 int32_t init_combo_classes()
9788 {
9789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
121 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9790
2/2
✓ Branch 0 taken 21538 times.
✓ Branch 1 taken 121 times.
21659 for(int32_t i=0; i<cMAX; i++)
9791 {
9792 21538 combo_class_buf[i] = default_combo_classes[i];
9793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21538 times.
21538 if ( char const* nm = zi->getComboTypeName(i) )
9794 {
9795 21538 size_t len = strlen(nm);
9796
2/2
✓ Branch 0 taken 1378432 times.
✓ Branch 1 taken 21538 times.
1399970 for ( size_t q = 0; q < 64; q++ )
9797 {
9798
2/2
✓ Branch 0 taken 319198 times.
✓ Branch 1 taken 1059234 times.
1378432 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9799 1378432 }
9800 21538 }
9801 21538 }
9802
9803 121 return 0;
9804 }
9805
9806 59 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
9807 {
9808
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 assert(v_herosprites < 6);
9809 //these are here to bypass compiler warnings about unused arguments
9810 59 cv_herosprites=cv_herosprites;
9811
9812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(keepdata)
9813 {
9814 59 zinit.hero_swim_speed=67; //default
9815 59 setupherotiles(zinit.heroAnimationStyle);
9816 59 setupherodefenses();
9817 59 setupherooffsets();
9818 59 }
9819
9820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(v_herosprites>=0)
9821 {
9822 word tile, tile2;
9823 byte flip, extend, dummy_byte;
9824
9825
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 59 times.
295 for(int32_t i=0; i<4; i++)
9826 {
9827
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_igetw(&tile,f,keepdata))
9828 {
9829 return qe_invalid;
9830 }
9831
9832
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&flip,f,keepdata))
9833 {
9834 return qe_invalid;
9835 }
9836
9837
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&extend,f,keepdata))
9838 {
9839 return qe_invalid;
9840 }
9841
9842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236 times.
236 if(keepdata)
9843 {
9844 236 walkspr[i][spr_tile]=(int32_t)tile;
9845 236 walkspr[i][spr_flip]=(int32_t)flip;
9846 236 walkspr[i][spr_extend]=(int32_t)extend;
9847 236 }
9848 236 }
9849
9850
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 59 times.
295 for(int32_t i=0; i<4; i++)
9851 {
9852
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_igetw(&tile,f,keepdata))
9853 {
9854 return qe_invalid;
9855 }
9856
9857
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&flip,f,keepdata))
9858 {
9859 return qe_invalid;
9860 }
9861
9862
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&extend,f,keepdata))
9863 {
9864 return qe_invalid;
9865 }
9866
9867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236 times.
236 if(keepdata)
9868 {
9869 236 stabspr[i][spr_tile]=(int32_t)tile;
9870 236 stabspr[i][spr_flip]=(int32_t)flip;
9871 236 stabspr[i][spr_extend]=(int32_t)extend;
9872 236 }
9873 236 }
9874
9875
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 59 times.
295 for(int32_t i=0; i<4; i++)
9876 {
9877
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_igetw(&tile,f,keepdata))
9878 {
9879 return qe_invalid;
9880 }
9881
9882
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&flip,f,keepdata))
9883 {
9884 return qe_invalid;
9885 }
9886
9887
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&extend,f,keepdata))
9888 {
9889 return qe_invalid;
9890 }
9891
9892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236 times.
236 if(keepdata)
9893 {
9894 236 slashspr[i][spr_tile]=(int32_t)tile;
9895 236 slashspr[i][spr_flip]=(int32_t)flip;
9896 236 slashspr[i][spr_extend]=(int32_t)extend;
9897 236 }
9898 236 }
9899
9900
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 59 times.
295 for(int32_t i=0; i<4; i++)
9901 {
9902
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_igetw(&tile,f,keepdata))
9903 {
9904 return qe_invalid;
9905 }
9906
9907
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&flip,f,keepdata))
9908 {
9909 return qe_invalid;
9910 }
9911
9912
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&extend,f,keepdata))
9913 {
9914 return qe_invalid;
9915 }
9916
9917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236 times.
236 if(keepdata)
9918 {
9919 236 floatspr[i][spr_tile]=(int32_t)tile;
9920 236 floatspr[i][spr_flip]=(int32_t)flip;
9921 236 floatspr[i][spr_extend]=(int32_t)extend;
9922 236 }
9923 236 }
9924
9925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(v_herosprites>1)
9926 {
9927
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 59 times.
295 for(int32_t i=0; i<4; i++)
9928 {
9929
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_igetw(&tile,f,keepdata))
9930 {
9931 return qe_invalid;
9932 }
9933
9934
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&flip,f,keepdata))
9935 {
9936 return qe_invalid;
9937 }
9938
9939
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&extend,f,keepdata))
9940 {
9941 return qe_invalid;
9942 }
9943
9944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236 times.
236 if(keepdata)
9945 {
9946 236 swimspr[i][spr_tile]=(int32_t)tile;
9947 236 swimspr[i][spr_flip]=(int32_t)flip;
9948 236 swimspr[i][spr_extend]=(int32_t)extend;
9949 236 }
9950 236 }
9951 59 }
9952
9953
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 59 times.
295 for(int32_t i=0; i<4; i++)
9954 {
9955
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_igetw(&tile,f,keepdata))
9956 {
9957 return qe_invalid;
9958 }
9959
9960
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&flip,f,keepdata))
9961 {
9962 return qe_invalid;
9963 }
9964
9965
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&extend,f,keepdata))
9966 {
9967 return qe_invalid;
9968 }
9969
9970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236 times.
236 if(keepdata)
9971 {
9972 236 divespr[i][spr_tile]=(int32_t)tile;
9973 236 divespr[i][spr_flip]=(int32_t)flip;
9974 236 divespr[i][spr_extend]=(int32_t)extend;
9975 236 }
9976 236 }
9977
9978
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 59 times.
295 for(int32_t i=0; i<4; i++)
9979 {
9980
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_igetw(&tile,f,keepdata))
9981 {
9982 return qe_invalid;
9983 }
9984
9985
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&flip,f,keepdata))
9986 {
9987 return qe_invalid;
9988 }
9989
9990
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&extend,f,keepdata))
9991 {
9992 return qe_invalid;
9993 }
9994
9995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236 times.
236 if(keepdata)
9996 {
9997 236 poundspr[i][spr_tile]=(int32_t)tile;
9998 236 poundspr[i][spr_flip]=(int32_t)flip;
9999 236 poundspr[i][spr_extend]=(int32_t)extend;
10000 236 }
10001 236 }
10002
10003
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&tile,f,keepdata))
10004 {
10005 return qe_invalid;
10006 }
10007
10008 59 flip=0;
10009
10010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(v_herosprites>0)
10011 {
10012
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_getc(&flip,f,keepdata))
10013 {
10014 return qe_invalid;
10015 }
10016 59 }
10017
10018
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_getc(&extend,f,keepdata))
10019 {
10020 return qe_invalid;
10021 }
10022
10023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(keepdata)
10024 {
10025 59 castingspr[spr_tile]=(int32_t)tile;
10026 59 castingspr[spr_flip]=(int32_t)flip;
10027 59 castingspr[spr_extend]=(int32_t)extend;
10028 59 }
10029
10030
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(v_herosprites>0)
10031 {
10032 59 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10033
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 59 times.
177 for(int32_t i=0; i<2; i++)
10034 {
10035
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 118 times.
354 for(int32_t j=0; j<num_holdsprs; j++)
10036 {
10037
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_igetw(&tile,f,keepdata))
10038 {
10039 return qe_invalid;
10040 }
10041
10042
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&flip,f,keepdata))
10043 {
10044 return qe_invalid;
10045 }
10046
10047
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&extend,f,keepdata))
10048 {
10049 return qe_invalid;
10050 }
10051
10052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236 times.
236 if(keepdata)
10053 {
10054 236 holdspr[i][j][spr_tile]=(int32_t)tile;
10055 236 holdspr[i][j][spr_flip]=(int32_t)flip;
10056 236 holdspr[i][j][spr_extend]=(int32_t)extend;
10057 236 }
10058 236 }
10059 118 }
10060 59 }
10061 else
10062 {
10063 for(int32_t i=0; i<2; i++)
10064 {
10065 if(!p_igetw(&tile,f,keepdata))
10066 {
10067 return qe_invalid;
10068 }
10069
10070 if(!p_igetw(&tile2,f,keepdata))
10071 {
10072 return qe_invalid;
10073 }
10074
10075 if(!p_getc(&extend,f,keepdata))
10076 {
10077 return qe_invalid;
10078 }
10079
10080 if(keepdata)
10081 {
10082 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10083 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10084 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10085 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10086 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10087 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10088 }
10089 }
10090 }
10091
10092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(v_herosprites>2)
10093 {
10094
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 59 times.
295 for(int32_t i=0; i<4; i++)
10095 {
10096
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_igetw(&tile,f,keepdata))
10097 {
10098 return qe_invalid;
10099 }
10100
10101
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&flip,f,keepdata))
10102 {
10103 return qe_invalid;
10104 }
10105
10106
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&extend,f,keepdata))
10107 {
10108 return qe_invalid;
10109 }
10110
10111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236 times.
236 if(keepdata)
10112 {
10113 236 jumpspr[i][spr_tile]=(int32_t)tile;
10114 236 jumpspr[i][spr_flip]=(int32_t)flip;
10115 236 jumpspr[i][spr_extend]=(int32_t)extend;
10116 236 }
10117 236 }
10118 59 }
10119
10120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(v_herosprites>3)
10121 {
10122
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 59 times.
295 for(int32_t i=0; i<4; i++)
10123 {
10124
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_igetw(&tile,f,keepdata))
10125 {
10126 return qe_invalid;
10127 }
10128
10129
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&flip,f,keepdata))
10130 {
10131 return qe_invalid;
10132 }
10133
10134
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(!p_getc(&extend,f,keepdata))
10135 {
10136 return qe_invalid;
10137 }
10138
10139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236 times.
236 if(keepdata)
10140 {
10141 236 chargespr[i][spr_tile]=(int32_t)tile;
10142 236 chargespr[i][spr_flip]=(int32_t)flip;
10143 236 chargespr[i][spr_extend]=(int32_t)extend;
10144 236 }
10145 236 }
10146 59 }
10147
10148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(v_herosprites>4)
10149 {
10150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(!p_getc(&dummy_byte,f,keepdata))
10151 {
10152 return qe_invalid;
10153 }
10154
10155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(keepdata)
10156 {
10157 59 zinit.hero_swim_speed=(byte)dummy_byte;
10158 59 }
10159 59 }
10160
10161
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(keepdata)
10162 {
10163 59 memset(frozenspr, 0, sizeof(frozenspr));
10164 59 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10165 59 memset(onfirespr, 0, sizeof(onfirespr));
10166 59 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10167 59 memset(diggingspr, 0, sizeof(diggingspr));
10168 59 memset(usingrodspr, 0, sizeof(usingrodspr));
10169 59 memset(usingcanespr, 0, sizeof(usingcanespr));
10170 59 memset(pushingspr, 0, sizeof(pushingspr));
10171 59 memset(liftingspr, 0, sizeof(liftingspr));
10172 59 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10173 59 memset(stunnedspr, 0, sizeof(stunnedspr));
10174 59 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10175 59 memset(fallingspr, 0, sizeof(fallingspr));
10176 59 memset(shockedspr, 0, sizeof(shockedspr));
10177 59 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10178 59 memset(pullswordspr, 0, sizeof(pullswordspr));
10179 59 memset(readingspr, 0, sizeof(readingspr));
10180 59 memset(slash180spr, 0, sizeof(slash180spr));
10181 59 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10182 59 memset(dashspr, 0, sizeof(dashspr));
10183 59 memset(bonkspr, 0, sizeof(bonkspr));
10184 59 memset(medallionsprs, 0, sizeof(medallionsprs));
10185 59 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10186 59 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10187
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 59 times.
295 for(int32_t q = 0; q < 4; ++q)
10188 {
10189
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 236 times.
944 for(int32_t p = 0; p < 3; ++p)
10190 {
10191 708 drowningspr[q][p] = divespr[q][p];
10192 708 drowning_lavaspr[q][p] = divespr[q][p];
10193 708 }
10194 236 }
10195 59 memset(sideswimspr, 0, sizeof(sideswimspr));
10196 59 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10197 59 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10198 59 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10199 59 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10200 59 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10201 59 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10202 59 }
10203 59 }
10204
10205 59 return 0;
10206 59 }
10207
10208 510 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10209 {
10210 510 arr[spr_tile] = tile;
10211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 510 times.
510 arr[spr_flip] = (flip > 3 ? 0 : flip);
10212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 510 times.
510 arr[spr_extend] = (ext > 2 ? 0 : ext);
10213 510 }
10214 //Used to read the player sprites as int32_t, not word.
10215 3 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
10216 {
10217 //these are here to bypass compiler warnings about unused arguments
10218 3 cv_herosprites=cv_herosprites;
10219
10220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata)
10221 {
10222 3 zinit.hero_swim_speed=67; //default
10223 3 setupherotiles(zinit.heroAnimationStyle);
10224 3 setupherodefenses();
10225 3 setupherooffsets();
10226 3 }
10227
10228 int32_t tile, tile2;
10229 byte flip, extend, dummy_byte;
10230
10231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(v_herosprites>=0)
10232 {
10233
10234
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10235 {
10236
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10237 {
10238 return qe_invalid;
10239 }
10240
10241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10242 {
10243 return qe_invalid;
10244 }
10245
10246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10247 {
10248 return qe_invalid;
10249 }
10250
10251 12 if(keepdata)
10252 {
10253 12 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10254 12 }
10255 12 }
10256
10257
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10258 {
10259
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10260 {
10261 return qe_invalid;
10262 }
10263
10264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10265 {
10266 return qe_invalid;
10267 }
10268
10269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10270 {
10271 return qe_invalid;
10272 }
10273
10274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10275 {
10276 12 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10277 12 }
10278 12 }
10279
10280
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10281 {
10282
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10283 {
10284 return qe_invalid;
10285 }
10286
10287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10288 {
10289 return qe_invalid;
10290 }
10291
10292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10293 {
10294 return qe_invalid;
10295 }
10296
10297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10298 {
10299 12 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10300 12 }
10301 12 }
10302
10303
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10304 {
10305
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10306 {
10307 return qe_invalid;
10308 }
10309
10310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10311 {
10312 return qe_invalid;
10313 }
10314
10315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10316 {
10317 return qe_invalid;
10318 }
10319
10320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10321 {
10322 12 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10323 12 }
10324 12 }
10325
10326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(v_herosprites>1)
10327 {
10328
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10329 {
10330
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10331 {
10332 return qe_invalid;
10333 }
10334
10335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10336 {
10337 return qe_invalid;
10338 }
10339
10340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10341 {
10342 return qe_invalid;
10343 }
10344
10345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10346 {
10347 12 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10348 12 }
10349 12 }
10350 3 }
10351
10352
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10353 {
10354
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10355 {
10356 return qe_invalid;
10357 }
10358
10359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10360 {
10361 return qe_invalid;
10362 }
10363
10364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10365 {
10366 return qe_invalid;
10367 }
10368
10369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10370 {
10371 12 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10372 12 }
10373 12 }
10374
10375
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10376 {
10377
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10378 {
10379 return qe_invalid;
10380 }
10381
10382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10383 {
10384 return qe_invalid;
10385 }
10386
10387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10388 {
10389 return qe_invalid;
10390 }
10391
10392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10393 {
10394 12 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10395 12 }
10396 12 }
10397
10398
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&tile,f,keepdata))
10399 {
10400 return qe_invalid;
10401 }
10402
10403 3 flip=0;
10404
10405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(v_herosprites>0)
10406 {
10407
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&flip,f,keepdata))
10408 {
10409 return qe_invalid;
10410 }
10411 3 }
10412
10413
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&extend,f,keepdata))
10414 {
10415 return qe_invalid;
10416 }
10417
10418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata)
10419 {
10420 3 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10421 3 }
10422
10423
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(v_herosprites>0)
10424 {
10425 3 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10426
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
9 for(int32_t i=0; i<2; i++)
10427 {
10428
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 for(int32_t j=0; j<num_holdsprs; j++)
10429 {
10430
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&tile,f,keepdata))
10431 {
10432 return qe_invalid;
10433 }
10434
10435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(!p_getc(&flip,f,keepdata))
10436 {
10437 return qe_invalid;
10438 }
10439
10440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(!p_getc(&extend,f,keepdata))
10441 {
10442 return qe_invalid;
10443 }
10444
10445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(keepdata)
10446 {
10447 18 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10448 18 }
10449 18 }
10450 6 }
10451 3 }
10452 else
10453 {
10454 for(int32_t i=0; i<2; i++)
10455 {
10456 if(!p_igetl(&tile,f,keepdata))
10457 {
10458 return qe_invalid;
10459 }
10460
10461 if(!p_igetl(&tile2,f,keepdata))
10462 {
10463 return qe_invalid;
10464 }
10465
10466 if(!p_getc(&extend,f,keepdata))
10467 {
10468 return qe_invalid;
10469 }
10470
10471 if(keepdata)
10472 {
10473 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10474 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10475 }
10476 }
10477 }
10478
10479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(v_herosprites>2)
10480 {
10481
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10482 {
10483
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10484 {
10485 return qe_invalid;
10486 }
10487
10488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10489 {
10490 return qe_invalid;
10491 }
10492
10493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10494 {
10495 return qe_invalid;
10496 }
10497
10498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10499 {
10500 12 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10501 12 }
10502 12 }
10503 3 }
10504
10505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(v_herosprites>3)
10506 {
10507
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<4; i++)
10508 {
10509
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10510 {
10511 return qe_invalid;
10512 }
10513
10514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10515 {
10516 return qe_invalid;
10517 }
10518
10519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10520 {
10521 return qe_invalid;
10522 }
10523
10524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10525 {
10526 12 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10527 12 }
10528 12 }
10529 3 }
10530
10531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(v_herosprites>4)
10532 {
10533
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&dummy_byte,f,keepdata))
10534 {
10535 return qe_invalid;
10536 }
10537
10538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata)
10539 {
10540 3 zinit.hero_swim_speed=(byte)dummy_byte;
10541 3 }
10542 3 }
10543
10544
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(v_herosprites>6)
10545 {
10546
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10547 {
10548
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10549 return qe_invalid;
10550
10551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10552 return qe_invalid;
10553
10554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10555 return qe_invalid;
10556
10557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10558 {
10559 12 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10560 12 }
10561 12 }
10562
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10563 {
10564
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10565 return qe_invalid;
10566
10567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10568 return qe_invalid;
10569
10570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10571 return qe_invalid;
10572
10573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10574 {
10575 12 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10576 12 }
10577 12 }
10578
10579
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10580 {
10581
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10582 return qe_invalid;
10583
10584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10585 return qe_invalid;
10586
10587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10588 return qe_invalid;
10589
10590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10591 {
10592 12 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10593 12 }
10594 12 }
10595
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10596 {
10597
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10598 return qe_invalid;
10599
10600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10601 return qe_invalid;
10602
10603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10604 return qe_invalid;
10605
10606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10607 {
10608 12 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10609 12 }
10610 12 }
10611
10612
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10613 {
10614
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10615 return qe_invalid;
10616
10617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10618 return qe_invalid;
10619
10620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10621 return qe_invalid;
10622
10623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10624 {
10625 12 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10626 12 }
10627 12 }
10628
10629
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10630 {
10631
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10632 return qe_invalid;
10633
10634
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10635 return qe_invalid;
10636
10637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10638 return qe_invalid;
10639
10640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10641 {
10642 12 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10643 12 }
10644 12 }
10645
10646
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10647 {
10648
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10649 return qe_invalid;
10650
10651
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10652 return qe_invalid;
10653
10654
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10655 return qe_invalid;
10656
10657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10658 {
10659 12 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10660 12 }
10661 12 }
10662
10663
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10664 {
10665
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10666 return qe_invalid;
10667
10668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10669 return qe_invalid;
10670
10671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10672 return qe_invalid;
10673
10674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10675 {
10676 12 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10677 12 }
10678 12 }
10679
10680
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10681 {
10682
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10683 return qe_invalid;
10684
10685
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10686 return qe_invalid;
10687
10688
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10689 return qe_invalid;
10690
10691 12 byte frames = 0;
10692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(v_herosprites > 15)
10693 {
10694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&frames,f,keepdata))
10695 return qe_invalid;
10696 12 }
10697
10698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10699 {
10700 12 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10701 12 liftingspr[q][spr_frames] = frames;
10702 12 }
10703 12 }
10704
10705
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10706 {
10707
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10708 return qe_invalid;
10709
10710
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10711 return qe_invalid;
10712
10713
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10714 return qe_invalid;
10715
10716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10717 {
10718 12 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10719 12 }
10720 12 }
10721
10722
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10723 {
10724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_igetl(&tile,f,keepdata))
10725 return qe_invalid;
10726
10727
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10728 return qe_invalid;
10729
10730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10731 return qe_invalid;
10732
10733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10734 {
10735 12 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10736 12 }
10737 12 }
10738
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10739 {
10740
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10741 return qe_invalid;
10742
10743
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10744 return qe_invalid;
10745
10746
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10747 return qe_invalid;
10748
10749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10750 {
10751 12 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10752 12 }
10753 12 }
10754
10755
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10756 {
10757
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10758 return qe_invalid;
10759
10760
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10761 return qe_invalid;
10762
10763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10764 return qe_invalid;
10765
10766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10767 {
10768 12 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10769 12 }
10770 12 }
10771
10772
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10773 {
10774
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10775 return qe_invalid;
10776
10777
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10778 return qe_invalid;
10779
10780
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10781 return qe_invalid;
10782
10783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10784 {
10785 12 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10786 12 }
10787 12 }
10788
10789
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10790 {
10791
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10792 return qe_invalid;
10793
10794
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10795 return qe_invalid;
10796
10797
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10798 return qe_invalid;
10799
10800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10801 {
10802 12 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10803 12 }
10804 12 }
10805
10806
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10807 {
10808
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10809 return qe_invalid;
10810
10811
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10812 return qe_invalid;
10813
10814
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10815 return qe_invalid;
10816
10817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10818 {
10819 12 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10820 12 }
10821 12 }
10822
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10823 {
10824
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10825 return qe_invalid;
10826
10827
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10828 return qe_invalid;
10829
10830
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10831 return qe_invalid;
10832
10833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10834 {
10835 12 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10836 12 }
10837 12 }
10838
10839
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10840 {
10841
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10842 return qe_invalid;
10843
10844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10845 return qe_invalid;
10846
10847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10848 return qe_invalid;
10849
10850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10851 {
10852 12 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10853 12 }
10854 12 }
10855
10856
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10857 {
10858
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10859 return qe_invalid;
10860
10861
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10862 return qe_invalid;
10863
10864
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10865 return qe_invalid;
10866
10867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10868 {
10869 12 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10870 12 }
10871 12 }
10872
10873
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10874 {
10875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_igetl(&tile,f,keepdata))
10876 return qe_invalid;
10877
10878
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10879 return qe_invalid;
10880
10881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10882 return qe_invalid;
10883
10884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10885 {
10886 12 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10887 12 }
10888 12 }
10889
10890
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10891 {
10892
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10893 return qe_invalid;
10894
10895
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10896 return qe_invalid;
10897
10898
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10899 return qe_invalid;
10900
10901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10902 {
10903 12 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10904 12 }
10905 12 }
10906
10907
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10908 {
10909
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10910 return qe_invalid;
10911
10912
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10913 return qe_invalid;
10914
10915
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10916 return qe_invalid;
10917
10918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10919 {
10920 12 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10921 12 }
10922 12 }
10923
10924
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10925 {
10926
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10927 return qe_invalid;
10928
10929
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&flip,f,keepdata))
10930 return qe_invalid;
10931
10932
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&extend,f,keepdata))
10933 return qe_invalid;
10934
10935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10936 {
10937 12 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10938 12 }
10939 12 }
10940
10941
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3 times.
12 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10942 {
10943
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetl(&tile,f,keepdata))
10944 return qe_invalid;
10945
10946
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&flip,f,keepdata))
10947 return qe_invalid;
10948
10949
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&extend,f,keepdata))
10950 return qe_invalid;
10951
10952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
10953 {
10954 9 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10955 9 }
10956 9 }
10957 3 }
10958 else if(keepdata)
10959 {
10960 memset(frozenspr, 0, sizeof(frozenspr));
10961 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10962 memset(onfirespr, 0, sizeof(onfirespr));
10963 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10964 memset(diggingspr, 0, sizeof(diggingspr));
10965 memset(usingrodspr, 0, sizeof(usingrodspr));
10966 memset(usingcanespr, 0, sizeof(usingcanespr));
10967 memset(pushingspr, 0, sizeof(pushingspr));
10968 memset(liftingspr, 0, sizeof(liftingspr));
10969 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10970 memset(stunnedspr, 0, sizeof(stunnedspr));
10971 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10972 memset(fallingspr, 0, sizeof(fallingspr));
10973 memset(shockedspr, 0, sizeof(shockedspr));
10974 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10975 memset(pullswordspr, 0, sizeof(pullswordspr));
10976 memset(readingspr, 0, sizeof(readingspr));
10977 memset(slash180spr, 0, sizeof(slash180spr));
10978 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10979 memset(dashspr, 0, sizeof(dashspr));
10980 memset(bonkspr, 0, sizeof(bonkspr));
10981 memset(medallionsprs, 0, sizeof(medallionsprs));
10982 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10983 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10984 for(int32_t q = 0; q < 4; ++q)
10985 {
10986 for(int32_t p = 0; p < 3; ++p)
10987 {
10988 drowningspr[q][p] = divespr[q][p];
10989 drowning_lavaspr[q][p] = divespr[q][p];
10990 }
10991 }
10992 }
10993
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (v_herosprites > 8)
10994 {
10995
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
10996 {
10997
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10998 return qe_invalid;
10999
11000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
11001 return qe_invalid;
11002
11003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
11004 return qe_invalid;
11005
11006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
11007 {
11008 12 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11009 12 }
11010 12 }
11011 3 }
11012 else if (keepdata)
11013 {
11014 memset(sideswimspr, 0, sizeof(sideswimspr));
11015 }
11016
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (v_herosprites > 9)
11017 {
11018
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
11019 {
11020
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
11021 return qe_invalid;
11022
11023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
11024 return qe_invalid;
11025
11026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
11027 return qe_invalid;
11028
11029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
11030 {
11031 12 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11032 12 }
11033 12 }
11034
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
11035 {
11036
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
11037 return qe_invalid;
11038
11039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
11040 return qe_invalid;
11041
11042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
11043 return qe_invalid;
11044
11045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
11046 {
11047 12 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11048 12 }
11049 12 }
11050
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
11051 {
11052
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
11053 return qe_invalid;
11054
11055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
11056 return qe_invalid;
11057
11058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
11059 return qe_invalid;
11060
11061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
11062 {
11063 12 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11064 12 }
11065 12 }
11066
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
11067 {
11068
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
11069 return qe_invalid;
11070
11071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
11072 return qe_invalid;
11073
11074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
11075 return qe_invalid;
11076
11077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
11078 {
11079 12 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11080 12 }
11081 12 }
11082 3 }
11083 else if (keepdata)
11084 {
11085 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11086 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11087 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11088 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11089 }
11090
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (v_herosprites > 10)
11091 {
11092
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
11093 {
11094 int32_t hmr;
11095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_igetl(&hmr,f,keepdata))
11096 return qe_invalid;
11097
11098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
11099 {
11100 12 hammeroffsets[q] = hmr;
11101 12 }
11102 12 }
11103 3 }
11104 else if (keepdata)
11105 {
11106 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11107 }
11108
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (v_herosprites > 11)
11109 {
11110
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3 times.
12 for(int32_t q = 0; q < 3; ++q)
11111 {
11112
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetl(&tile,f,keepdata))
11113 return qe_invalid;
11114
11115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!p_getc(&flip,f,keepdata))
11116 return qe_invalid;
11117
11118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!p_getc(&extend,f,keepdata))
11119 return qe_invalid;
11120
11121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
11122 {
11123 9 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11124 9 }
11125 9 }
11126 3 }
11127 else if (keepdata)
11128 {
11129 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11130 }
11131
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (v_herosprites > 12)
11132 {
11133
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&tile,f,keepdata))
11134 return qe_invalid;
11135
11136
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&flip,f,keepdata))
11137 return qe_invalid;
11138
11139
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&extend,f,keepdata))
11140 return qe_invalid;
11141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (keepdata)
11142 {
11143 3 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11144 3 }
11145
11146 3 }
11147 else if (keepdata)
11148 {
11149 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11150 }
11151
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (v_herosprites > 13)
11152 {
11153
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
11154 {
11155
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
11156 return qe_invalid;
11157
11158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
11159 return qe_invalid;
11160
11161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
11162 return qe_invalid;
11163
11164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
11165 {
11166 12 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11167 12 }
11168 12 }
11169 3 }
11170 else if (keepdata)
11171 {
11172 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11173 }
11174
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (v_herosprites > 14)
11175 {
11176
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t q = 0; q < 4; ++q)
11177 {
11178
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
11179 return qe_invalid;
11180
11181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
11182 return qe_invalid;
11183
11184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
11185 return qe_invalid;
11186
11187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
11188 {
11189 12 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11190 12 }
11191 12 }
11192 3 }
11193 else if (keepdata)
11194 {
11195 memset(revslashspr, 0, sizeof(revslashspr));
11196 }
11197
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (v_herosprites > 7)
11198 {
11199 3 int32_t num_defense = wMax;
11200 3 byte def = 0;
11201
11202 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11203 /*if(v_herosprites > [x])
11204 * {
11205 * num_defense = 146 //value of wMax on version 8
11206 * }
11207 */
11208
11209
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 3 times.
441 for (int32_t q = 0; q < num_defense; q++)
11210 {
11211
1/2
✓ Branch 0 taken 438 times.
✗ Branch 1 not taken.
438 if (!p_getc(&def, f, keepdata))
11212 return qe_invalid;
11213
11214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 438 times.
438 if (keepdata)
11215 {
11216 438 hero_defence[q] = def;
11217 438 }
11218 438 }
11219 3 }
11220 else if (keepdata)
11221 {
11222 int32_t num_defense = wMax;
11223 for (int32_t q = 0; q < num_defense; q++)
11224 {
11225 hero_defence[q] = 0;
11226 }
11227 }
11228 3 }
11229
11230 3 return 0;
11231 3 }
11232
11233
11234 62 int32_t readherosprites(PACKFILE *f, zquestheader *Header, bool keepdata)
11235 {
11236 //these are here to bypass compiler warnings about unused arguments
11237 62 Header=Header;
11238
11239 dword dummy;
11240 62 word s_version=0, s_cversion=0;
11241
11242 //section version info
11243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(!p_igetw(&s_version,f,true))
11244 {
11245 return qe_invalid;
11246 }
11247
11248 62 FFCore.quest_format[vHeroSprites] = s_version;
11249
11250 //al_trace("Player sprites version %d\n", s_version);
11251
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_cversion,f,true))
11252 {
11253 return qe_invalid;
11254 }
11255
11256 //section size
11257
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&dummy,f,true))
11258 {
11259 return qe_invalid;
11260 }
11261
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if ( s_version >= 6 )
11262 {
11263 //al_trace("Reading Player Sprites v6\n");
11264 3 return readherosprites3(f, s_version, dummy, keepdata);
11265 }
11266 59 else return readherosprites2(f, s_version, dummy, keepdata);
11267 62 }
11268
11269 62 int32_t readsubscreens(PACKFILE *f, zquestheader *Header, bool keepdata)
11270 {
11271 int32_t dummy;
11272 62 word s_version=0, s_cversion=0;
11273
11274 //section version info
11275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(!p_igetw(&s_version,f,true))
11276 {
11277 return qe_invalid;
11278 }
11279
11280 62 FFCore.quest_format[vSubscreen] = s_version;
11281
11282 //al_trace("Subscreens version %d\n", s_version);
11283
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_cversion,f,true))
11284 {
11285 return qe_invalid;
11286 }
11287
11288 //section size
11289
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&dummy,f,true))
11290 {
11291 return qe_invalid;
11292 }
11293
11294 //finally... section data
11295
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 62 times.
7998 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11296 {
11297 7936 int32_t ret = read_one_subscreen(f, Header, keepdata, i, s_version, s_cversion);
11298
11299
1/2
✓ Branch 0 taken 7936 times.
✗ Branch 1 not taken.
7936 if(ret!=0) return ret;
11300 7936 }
11301
11302 62 return 0;
11303 62 }
11304
11305 7936 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, bool keepdata, int32_t i, word s_version, word)
11306 {
11307 7936 int32_t numsub=0;
11308 7936 byte temp_ss=0;
11309 subscreen_object temp_sub_stack;
11310 7936 subscreen_object *temp_sub = &temp_sub_stack;
11311
11312 char tempname[64];
11313
11314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7936 times.
7936 if(!pfread(tempname,64,f,true))
11315 {
11316 return qe_invalid;
11317 }
11318
11319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7936 times.
7936 if(s_version > 1)
11320 {
11321
1/2
✓ Branch 0 taken 7936 times.
✗ Branch 1 not taken.
7936 if(!p_getc(&temp_ss,f,keepdata))
11322 {
11323 return qe_invalid;
11324 }
11325 7936 }
11326
11327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7936 times.
7936 if(s_version < 4)
11328 {
11329 uint8_t tmp=0;
11330
11331 if(!p_getc(&tmp,f,true))
11332 {
11333 return qe_invalid;
11334 }
11335
11336 numsub = (int32_t)tmp;
11337 }
11338 else
11339 {
11340 word tmp;
11341
11342
1/2
✓ Branch 0 taken 7936 times.
✗ Branch 1 not taken.
7936 if(!p_igetw(&tmp, f, true))
11343 {
11344 return qe_invalid;
11345 }
11346
11347 7936 numsub = (int32_t)tmp;
11348 }
11349
11350 int32_t j;
11351
11352
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15190 times.
✓ Branch 2 taken 7254 times.
✓ Branch 3 taken 7936 times.
15190 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11353 {
11354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7254 times.
7254 if(keepdata)
11355 {
11356 7254 memset(temp_sub,0,sizeof(subscreen_object));
11357
11358
2/2
✓ Branch 0 taken 890 times.
✓ Branch 1 taken 6364 times.
7254 switch(custom_subscreen[i].objects[j].type)
11359 {
11360 case ssoTEXT:
11361 case ssoTEXTBOX:
11362 case ssoCURRENTITEMTEXT:
11363 case ssoCURRENTITEMCLASSTEXT:
11364
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 890 times.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11365
11366 //fall through
11367 default:
11368 7254 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11369 7254 break;
11370 }
11371 7254 }
11372
11373
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_getc(&(temp_sub->type),f,true))
11374 {
11375 return qe_invalid;
11376 }
11377
11378
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_getc(&(temp_sub->pos),f,keepdata))
11379 {
11380 return qe_invalid;
11381 }
11382
11383
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(s_version < 5)
11384 {
11385 switch(temp_sub->pos)
11386 {
11387 case 0:
11388 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11389 break;
11390
11391 case 1:
11392 temp_sub->pos = sspUP;
11393 break;
11394
11395 case 2:
11396 temp_sub->pos = sspDOWN;
11397 break;
11398
11399 default:
11400 temp_sub->pos = 0;
11401 }
11402 }
11403
11404
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetw(&(temp_sub->x),f,keepdata))
11405 {
11406 return qe_invalid;
11407 }
11408
11409
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetw(&(temp_sub->y),f,keepdata))
11410 {
11411 return qe_invalid;
11412 }
11413
11414
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetw(&(temp_sub->w),f,keepdata))
11415 {
11416 return qe_invalid;
11417 }
11418
11419
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetw(&(temp_sub->h),f,keepdata))
11420 {
11421 return qe_invalid;
11422 }
11423
11424
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_getc(&(temp_sub->colortype1),f,keepdata))
11425 {
11426 return qe_invalid;
11427 }
11428
11429
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetw(&(temp_sub->color1),f,keepdata))
11430 {
11431 return qe_invalid;
11432 }
11433
11434
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_getc(&(temp_sub->colortype2),f,keepdata))
11435 {
11436 return qe_invalid;
11437 }
11438
11439
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetw(&(temp_sub->color2),f,keepdata))
11440 {
11441 return qe_invalid;
11442 }
11443
11444
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_getc(&(temp_sub->colortype3),f,keepdata))
11445 {
11446 return qe_invalid;
11447 }
11448
11449
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetw(&(temp_sub->color3),f,keepdata))
11450 {
11451 return qe_invalid;
11452 }
11453
11454
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetd(&(temp_sub->d1),f,keepdata))
11455 {
11456 return qe_invalid;
11457 }
11458
11459
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetd(&(temp_sub->d2),f,keepdata))
11460 {
11461 return qe_invalid;
11462 }
11463
11464
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetd(&(temp_sub->d3),f,keepdata))
11465 {
11466 return qe_invalid;
11467 }
11468
11469
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetd(&(temp_sub->d4),f,keepdata))
11470 {
11471 return qe_invalid;
11472 }
11473
11474
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetd(&(temp_sub->d5),f,keepdata))
11475 {
11476 return qe_invalid;
11477 }
11478
11479
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetd(&(temp_sub->d6),f,keepdata))
11480 {
11481 return qe_invalid;
11482 }
11483
11484
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetd(&(temp_sub->d7),f,keepdata))
11485 {
11486 return qe_invalid;
11487 }
11488
11489
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetd(&(temp_sub->d8),f,keepdata))
11490 {
11491 return qe_invalid;
11492 }
11493
11494
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetd(&(temp_sub->d9),f,keepdata))
11495 {
11496 return qe_invalid;
11497 }
11498
11499
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetd(&(temp_sub->d10),f,keepdata))
11500 {
11501 return qe_invalid;
11502 }
11503
11504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7254 times.
7254 if(s_version < 2)
11505 {
11506 if(!p_igetl(&(temp_sub->speed),f,keepdata))
11507 {
11508 return qe_invalid;
11509 }
11510
11511 if(!p_igetl(&(temp_sub->delay),f,keepdata))
11512 {
11513 return qe_invalid;
11514 }
11515
11516 if(!p_igetl(&(temp_sub->frame),f,keepdata))
11517 {
11518 return qe_invalid;
11519 }
11520 }
11521 else
11522 {
11523
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_getc(&(temp_sub->speed),f,keepdata))
11524 {
11525 return qe_invalid;
11526 }
11527
11528
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_getc(&(temp_sub->delay),f,keepdata))
11529 {
11530 return qe_invalid;
11531 }
11532
11533
1/2
✓ Branch 0 taken 7254 times.
✗ Branch 1 not taken.
7254 if(!p_igetw(&(temp_sub->frame),f,keepdata))
11534 {
11535 return qe_invalid;
11536 }
11537 }
11538
11539 7254 int32_t temp_size=0;
11540
11541 // bool deletets = false;
11542
4/4
✓ Branch 0 taken 3187 times.
✓ Branch 1 taken 987 times.
✓ Branch 2 taken 2962 times.
✓ Branch 3 taken 118 times.
7254 switch(temp_sub->type)
11543 {
11544 case ssoTEXT:
11545 case ssoTEXTBOX:
11546 case ssoCURRENTITEMTEXT:
11547 case ssoCURRENTITEMCLASSTEXT:
11548 word temptempsize;
11549 /*uint8_t temp1;
11550 uint8_t temp2;
11551 temp2 = 0;
11552 if(!p_getc(&temp1,f,true))
11553 {
11554 return qe_invalid;
11555 }
11556 if(temp1)
11557 {
11558
11559 if(!p_getc(&temp2,f,true))
11560 {
11561 return qe_invalid;
11562 }
11563 }*/
11564
11565
1/2
✓ Branch 0 taken 987 times.
✗ Branch 1 not taken.
987 if(!p_igetw(&temptempsize,f,true))
11566 {
11567 return qe_invalid;
11568 }
11569
11570 //temptempsize = temp1 + (temp2 << 8);
11571 987 temp_size = (int32_t)temptempsize;
11572
11573 //if(temp_sub->dp1!=NULL) delete[] temp_sub->dp1;
11574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 987 times.
987 if(keepdata)
11575 {
11576 987 uint32_t char_length = temp_size+1;
11577 987 temp_sub->dp1 = new char[char_length]; //memory not freed
11578
11579 //deletets = true; //obsolete
11580 987 }
11581
11582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 987 times.
987 if(temp_size)
11583 {
11584
1/2
✓ Branch 0 taken 987 times.
✗ Branch 1 not taken.
987 if(!pfread(temp_sub->dp1,temp_size+1,f,keepdata))
11585 {
11586 return qe_invalid;
11587 }
11588 987 }
11589
11590 987 break;
11591
11592 case ssoLIFEMETER:
11593
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11594 temp_sub->d3 = 1;
11595
11596
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11597 {
11598 return qe_invalid;
11599 }
11600
11601 118 break;
11602
11603
11604 case ssoCURRENTITEM:
11605
11606
1/2
✓ Branch 0 taken 3187 times.
✗ Branch 1 not taken.
3187 if(s_version < 6)
11607 {
11608 switch(temp_sub->d1)
11609 {
11610 case ssiBOMB:
11611 temp_sub->d1 = itype_bomb;
11612 break;
11613
11614 case ssiSWORD:
11615 temp_sub->d1 = itype_sword;
11616 break;
11617
11618 case ssiSHIELD:
11619 temp_sub->d1 = itype_shield;
11620 break;
11621
11622 case ssiCANDLE:
11623 temp_sub->d1 = itype_candle;
11624 break;
11625
11626 case ssiLETTER:
11627 temp_sub->d1 = itype_letter;
11628 break;
11629
11630 case ssiPOTION:
11631 temp_sub->d1 = itype_potion;
11632 break;
11633
11634 case ssiLETTERPOTION:
11635 temp_sub->d1 = itype_letterpotion;
11636 break;
11637
11638 case ssiBOW:
11639 temp_sub->d1 = itype_bow;
11640 break;
11641
11642 case ssiARROW:
11643 temp_sub->d1 = itype_arrow;
11644 break;
11645
11646 case ssiBOWANDARROW:
11647 temp_sub->d1 = itype_bowandarrow;
11648 break;
11649
11650 case ssiBAIT:
11651 temp_sub->d1 = itype_bait;
11652 break;
11653
11654 case ssiRING:
11655 temp_sub->d1 = itype_ring;
11656 break;
11657
11658 case ssiBRACELET:
11659 temp_sub->d1 = itype_bracelet;
11660 break;
11661
11662 case ssiMAP:
11663 temp_sub->d1 = itype_map;
11664 break;
11665
11666 case ssiCOMPASS:
11667 temp_sub->d1 = itype_compass;
11668 break;
11669
11670 case ssiBOSSKEY:
11671 temp_sub->d1 = itype_bosskey;
11672 break;
11673
11674 case ssiMAGICKEY:
11675 temp_sub->d1 = itype_magickey;
11676 break;
11677
11678 case ssiBRANG:
11679 temp_sub->d1 = itype_brang;
11680 break;
11681
11682 case ssiWAND:
11683 temp_sub->d1 = itype_wand;
11684 break;
11685
11686 case ssiRAFT:
11687 temp_sub->d1 = itype_raft;
11688 break;
11689
11690 case ssiLADDER:
11691 temp_sub->d1 = itype_ladder;
11692 break;
11693
11694 case ssiWHISTLE:
11695 temp_sub->d1 = itype_whistle;
11696 break;
11697
11698 case ssiBOOK:
11699 temp_sub->d1 = itype_book;
11700 break;
11701
11702 case ssiWALLET:
11703 temp_sub->d1 = itype_wallet;
11704 break;
11705
11706 case ssiSBOMB:
11707 temp_sub->d1 = itype_sbomb;
11708 break;
11709
11710 case ssiHCPIECE:
11711 temp_sub->d1 = itype_heartpiece;
11712 break;
11713
11714 case ssiAMULET:
11715 temp_sub->d1 = itype_amulet;
11716 break;
11717
11718 case ssiFLIPPERS:
11719 temp_sub->d1 = itype_flippers;
11720 break;
11721
11722 case ssiHOOKSHOT:
11723 temp_sub->d1 = itype_hookshot;
11724 break;
11725
11726 case ssiLENS:
11727 temp_sub->d1 = itype_lens;
11728 break;
11729
11730 case ssiHAMMER:
11731 temp_sub->d1 = itype_hammer;
11732 break;
11733
11734 case ssiBOOTS:
11735 temp_sub->d1 = itype_boots;
11736 break;
11737
11738 case ssiDINSFIRE:
11739 temp_sub->d1 = itype_dinsfire;
11740 break;
11741
11742 case ssiFARORESWIND:
11743 temp_sub->d1 = itype_faroreswind;
11744 break;
11745
11746 case ssiNAYRUSLOVE:
11747 temp_sub->d1 = itype_nayruslove;
11748 break;
11749
11750 case ssiQUIVER:
11751 temp_sub->d1 = itype_quiver;
11752 break;
11753
11754 case ssiBOMBBAG:
11755 temp_sub->d1 = itype_bombbag;
11756 break;
11757
11758 case ssiCBYRNA:
11759 temp_sub->d1 = itype_cbyrna;
11760 break;
11761
11762 case ssiROCS:
11763 temp_sub->d1 = itype_rocs;
11764 break;
11765
11766 case ssiHOVERBOOTS:
11767 temp_sub->d1 = itype_hoverboots;
11768 break;
11769
11770 case ssiSPINSCROLL:
11771 temp_sub->d1 = itype_spinscroll;
11772 break;
11773
11774 case ssiCROSSSCROLL:
11775 temp_sub->d1 = itype_crossscroll;
11776 break;
11777
11778 case ssiQUAKESCROLL:
11779 temp_sub->d1 = itype_quakescroll;
11780 break;
11781
11782 case ssiWHISPRING:
11783 temp_sub->d1 = itype_whispring;
11784 break;
11785
11786 case ssiCHARGERING:
11787 temp_sub->d1 = itype_chargering;
11788 break;
11789
11790 case ssiPERILSCROLL:
11791 temp_sub->d1 = itype_perilscroll;
11792 break;
11793
11794 case ssiWEALTHMEDAL:
11795 temp_sub->d1 = itype_wealthmedal;
11796 break;
11797
11798 case ssiHEARTRING:
11799 temp_sub->d1 = itype_heartring;
11800 break;
11801
11802 case ssiMAGICRING:
11803 temp_sub->d1 = itype_magicring;
11804 break;
11805
11806 case ssiSPINSCROLL2:
11807 temp_sub->d1 = itype_spinscroll2;
11808 break;
11809
11810 case ssiQUAKESCROLL2:
11811 temp_sub->d1 = itype_quakescroll2;
11812 break;
11813
11814 case ssiAGONY:
11815 temp_sub->d1 = itype_agony;
11816 break;
11817
11818 case ssiSTOMPBOOTS:
11819 temp_sub->d1 = itype_stompboots;
11820 break;
11821
11822 case ssiWHIMSICALRING:
11823 temp_sub->d1 = itype_whimsicalring;
11824 break;
11825
11826 case ssiPERILRING:
11827 temp_sub->d1 = itype_perilring;
11828 break;
11829
11830 default:
11831 temp_sub->d1 += itype_custom1 - ssiMAX;
11832 }
11833 }
11834
11835 //fall-through
11836 default:
11837
1/2
✓ Branch 0 taken 6149 times.
✗ Branch 1 not taken.
6149 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11838 {
11839 return qe_invalid;
11840 }
11841
11842 6149 break;
11843 }
11844
11845
2/2
✓ Branch 0 taken 1629 times.
✓ Branch 1 taken 5625 times.
7254 if(s_version < 7)
11846 {
11847
1/3
✓ Branch 0 taken 5625 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
5625 switch(temp_sub->type)
11848 {
11849 case ssoMAGICGAUGE:
11850 {
11851 if(!temp_sub->d9)
11852 temp_sub->d9 = -1; //-1 now represents 'always'
11853 break;
11854 }
11855 case ssoLIFEGAUGE:
11856 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11857 break;
11858 }
11859 5625 }
11860
11861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7254 times.
7254 if(keepdata)
11862 {
11863
3/3
✓ Branch 0 taken 987 times.
✓ Branch 1 taken 6073 times.
✓ Branch 2 taken 194 times.
7254 switch(temp_sub->type)
11864 {
11865 case ssoTEXT:
11866 case ssoTEXTBOX:
11867 case ssoCURRENTITEMTEXT:
11868 case ssoCURRENTITEMCLASSTEXT:
11869
1/4
✓ Branch 0 taken 987 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
987 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
11870
11871 987 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11872 987 custom_subscreen[i].objects[j].dp1 = NULL;
11873 987 custom_subscreen[i].objects[j].dp1 = new char[temp_size+1];
11874 987 strcpy((char*)custom_subscreen[i].objects[j].dp1,(char*)temp_sub->dp1);
11875 987 break;
11876
11877 case ssoCOUNTER:
11878
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(s_version<3)
11879 {
11880 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11881 temp_sub->d8=0;
11882 }
11883
11884 default:
11885 6267 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11886 6267 break;
11887 }
11888
11889 7254 strcpy(custom_subscreen[i].name, tempname);
11890 7254 custom_subscreen[i].ss_type = temp_ss;
11891 7254 }
11892 7254 }
11893
11894
2/2
✓ Branch 0 taken 2024362 times.
✓ Branch 1 taken 7936 times.
2032298 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11895 {
11896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2024362 times.
2024362 if(keepdata)
11897 {
11898 //clear all unused object in this subscreen -DD
11899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2024362 times.
2024362 switch(custom_subscreen[i].objects[j].type)
11900 {
11901 case ssoTEXT:
11902 case ssoTEXTBOX:
11903 case ssoCURRENTITEMTEXT:
11904 case ssoCURRENTITEMCLASSTEXT:
11905 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11906
11907 //fall through
11908 default:
11909 2024362 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11910 2024362 break;
11911 }
11912 2024362 }
11913 2024362 }
11914
11915 7936 return 0;
11916 7936 }
11917
11918 1664 void reset_subscreen(subscreen_group *tempss)
11919 {
11920
2/2
✓ Branch 0 taken 425984 times.
✓ Branch 1 taken 1664 times.
427648 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11921 {
11922
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 425895 times.
425984 switch(tempss->objects[i].type)
11923 {
11924 case ssoTEXT:
11925 case ssoTEXTBOX:
11926 case ssoCURRENTITEMTEXT:
11927 case ssoCURRENTITEMCLASSTEXT:
11928
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11929
11930 //fall through
11931 default:
11932 425984 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11933 425984 break;
11934 }
11935 425984 }
11936 1664 }
11937
11938 13 void reset_subscreens()
11939 {
11940
2/2
✓ Branch 0 taken 1664 times.
✓ Branch 1 taken 13 times.
1677 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
11941 {
11942 1664 reset_subscreen(&custom_subscreen[i]);
11943 1664 }
11944 13 }
11945
11946 13 int32_t setupsubscreens()
11947 {
11948 13 reset_subscreens();
11949 13 int32_t tempsubscreen=zinit.subscreen;
11950 subscreen_object *tempsub;
11951
11952
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(tempsubscreen>=ssdtMAX)
11953 {
11954 tempsubscreen=0;
11955 }
11956
11957
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
13 switch(tempsubscreen)
11958 {
11959 case ssdtOLD:
11960 case ssdtNEWSUBSCR:
11961 case ssdtREV2:
11962 case ssdtBSZELDA:
11963 case ssdtBSZELDAMODIFIED:
11964 case ssdtBSZELDAENHANCED:
11965 case ssdtBSZELDACOMPLETE:
11966 {
11967 13 tempsub = default_subscreen_active[tempsubscreen][0];
11968 int32_t i;
11969
11970
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 845 times.
✓ Branch 3 taken 13 times.
858 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
11971 {
11972
2/3
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 803 times.
✗ Branch 2 not taken.
845 switch(tempsub[i].type)
11973 {
11974 case ssoTEXT:
11975 case ssoTEXTBOX:
11976 case ssoCURRENTITEMTEXT:
11977 case ssoCURRENTITEMCLASSTEXT:
11978
1/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
11979
11980 42 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11981 42 custom_subscreen[0].objects[i].dp1 = NULL;
11982 42 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
11983 42 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
11984 42 break;
11985
11986 case ssoLIFEMETER:
11987 {
11988 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11989
11990 if(get_bit(deprecated_rules, 12) != 0)
11991 custom_subscreen[0].objects[i].d3=1;
11992 else
11993 custom_subscreen[0].objects[i].d3=0;
11994
11995 break;
11996 }
11997 /*
11998 case ssoTRIFRAME:
11999 {
12000 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12001 custom_subscreen[0].objects[i].d1 = 8594;
12002 custom_subscreen[0].objects[i].d2 = 8;
12003 custom_subscreen[0].objects[i].d3 = 8771;
12004 custom_subscreen[0].objects[i].d4 = 8;
12005 custom_subscreen[0].objects[i].d5 = 1;
12006 custom_subscreen[0].objects[i].d6 = 1;
12007 break;
12008 }*/
12009
12010 default:
12011 803 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12012 803 break;
12013 }
12014 845 }
12015
12016 13 custom_subscreen[0].ss_type=sstACTIVE;
12017 13 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
12018 13 tempsub = default_subscreen_active[tempsubscreen][1];
12019
12020
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 845 times.
✓ Branch 3 taken 13 times.
858 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12021 {
12022
2/3
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 790 times.
✗ Branch 2 not taken.
845 switch(tempsub[i].type)
12023 {
12024 case ssoTEXT:
12025 case ssoTEXTBOX:
12026 case ssoCURRENTITEMTEXT:
12027 case ssoCURRENTITEMCLASSTEXT:
12028
1/4
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12029
12030 55 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12031 55 custom_subscreen[1].objects[i].dp1 = NULL;
12032 55 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12033 55 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12034 55 break;
12035
12036 case ssoLIFEMETER:
12037 {
12038 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12039
12040 if(get_bit(deprecated_rules, 12) != 0)
12041 custom_subscreen[1].objects[i].d3=1;
12042 else
12043 custom_subscreen[1].objects[i].d3=0;
12044
12045 break;
12046 }
12047 /*
12048 case ssoTRIFRAME:
12049 {
12050 custom_subscreen[1].objects[i].d1 = 8594;
12051 custom_subscreen[1].objects[i].d2 = 8;
12052 custom_subscreen[1].objects[i].d3 = 8771;
12053 custom_subscreen[1].objects[i].d4 = 8;
12054 custom_subscreen[1].objects[i].d5 = 1;
12055 custom_subscreen[1].objects[i].d6 = 1;
12056 break;
12057 }*/
12058
12059 default:
12060 790 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12061 790 break;
12062 }
12063 845 }
12064
12065 13 custom_subscreen[1].ss_type=sstACTIVE;
12066 13 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12067 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12068 13 tempsub = default_subscreen_passive[tempsubscreen][0];
12069
12070
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 273 times.
✓ Branch 2 taken 260 times.
✓ Branch 3 taken 13 times.
273 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12071 {
12072
3/3
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 208 times.
✓ Branch 2 taken 13 times.
260 switch(tempsub[i].type)
12073 {
12074 case ssoTEXT:
12075 case ssoTEXTBOX:
12076 case ssoCURRENTITEMTEXT:
12077 case ssoCURRENTITEMCLASSTEXT:
12078
1/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12079
12080 39 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12081 39 custom_subscreen[2].objects[i].dp1 = NULL;
12082 39 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12083 39 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12084 39 break;
12085
12086 case ssoLIFEMETER:
12087 {
12088 13 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12089
12090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(get_bit(deprecated_rules, 12) != 0)
12091 custom_subscreen[2].objects[i].d3=1;
12092 else
12093 13 custom_subscreen[2].objects[i].d3=0;
12094
12095 13 break;
12096 }
12097
12098 default:
12099 208 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12100 208 break;
12101 }
12102 260 }
12103
12104 13 custom_subscreen[2].ss_type=sstPASSIVE;
12105 13 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12106 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12107 13 tempsub = default_subscreen_passive[tempsubscreen][1];
12108
12109
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 260 times.
✓ Branch 2 taken 247 times.
✓ Branch 3 taken 13 times.
260 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12110 {
12111
3/3
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 13 times.
247 switch(tempsub[i].type)
12112 {
12113 case ssoTEXT:
12114 case ssoTEXTBOX:
12115 case ssoCURRENTITEMTEXT:
12116 case ssoCURRENTITEMCLASSTEXT:
12117
1/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12118
12119 39 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12120 39 custom_subscreen[3].objects[i].dp1 = NULL;
12121 39 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12122 39 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12123 39 break;
12124
12125 case ssoLIFEMETER:
12126 {
12127 13 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12128
12129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(get_bit(deprecated_rules, 12) != 0)
12130 custom_subscreen[3].objects[i].d3=1;
12131 else
12132 13 custom_subscreen[3].objects[i].d3=0;
12133
12134 13 break;
12135 }
12136
12137 default:
12138 195 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12139 195 break;
12140 }
12141 247 }
12142
12143 13 custom_subscreen[3].ss_type=sstPASSIVE;
12144 13 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12145 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12146 13 break;
12147 }
12148
12149 case ssdtZ3:
12150 {
12151 tempsub = z3_active_a;
12152 int32_t i;
12153
12154 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12155 {
12156 switch(tempsub[i].type)
12157 {
12158 case ssoTEXT:
12159 case ssoTEXTBOX:
12160 case ssoCURRENTITEMTEXT:
12161 case ssoCURRENTITEMCLASSTEXT:
12162 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12163
12164 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12165 custom_subscreen[0].objects[i].dp1 = NULL;
12166 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12167 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12168 break;
12169
12170 case ssoLIFEMETER:
12171 {
12172 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12173
12174 if(get_bit(deprecated_rules, 12) != 0)
12175 custom_subscreen[0].objects[i].d3=1;
12176 else
12177 custom_subscreen[0].objects[i].d3=0;
12178
12179 break;
12180 }
12181
12182 default:
12183 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12184 break;
12185 }
12186 }
12187
12188 custom_subscreen[0].ss_type=sstACTIVE;
12189 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12190 tempsub = z3_active_ab;
12191
12192 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12193 {
12194 switch(tempsub[i].type)
12195 {
12196 case ssoTEXT:
12197 case ssoTEXTBOX:
12198 case ssoCURRENTITEMTEXT:
12199 case ssoCURRENTITEMCLASSTEXT:
12200 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12201
12202 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12203 custom_subscreen[1].objects[i].dp1 = NULL;
12204 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12205 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12206 break;
12207
12208 case ssoLIFEMETER:
12209 {
12210 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12211
12212 if(get_bit(deprecated_rules, 12) != 0)
12213 custom_subscreen[1].objects[i].d3=1;
12214 else
12215 custom_subscreen[1].objects[i].d3=0;
12216
12217 break;
12218 }
12219
12220 default:
12221 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12222 break;
12223 }
12224 }
12225
12226 custom_subscreen[1].ss_type=sstACTIVE;
12227 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12228 tempsub = z3_passive_a;
12229
12230 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12231 {
12232 switch(tempsub[i].type)
12233 {
12234 case ssoTEXT:
12235 case ssoTEXTBOX:
12236 case ssoCURRENTITEMTEXT:
12237 case ssoCURRENTITEMCLASSTEXT:
12238 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12239
12240 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12241 custom_subscreen[2].objects[i].dp1 = NULL;
12242 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12243 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12244 break;
12245
12246 case ssoLIFEMETER:
12247 {
12248 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12249
12250 if(get_bit(deprecated_rules, 12) != 0)
12251 custom_subscreen[2].objects[i].d3=1;
12252 else
12253 custom_subscreen[2].objects[i].d3=0;
12254
12255 break;
12256 }
12257
12258 default:
12259 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12260 break;
12261 }
12262 }
12263
12264 custom_subscreen[2].ss_type=sstPASSIVE;
12265 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12266 tempsub = z3_passive_ab;
12267
12268 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12269 {
12270 switch(tempsub[i].type)
12271 {
12272 case ssoTEXT:
12273 case ssoTEXTBOX:
12274 case ssoCURRENTITEMTEXT:
12275 case ssoCURRENTITEMCLASSTEXT:
12276 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12277
12278 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12279 custom_subscreen[3].objects[i].dp1 = NULL;
12280 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12281 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12282 break;
12283
12284 case ssoLIFEMETER:
12285 {
12286 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12287
12288 if(get_bit(deprecated_rules, 12) != 0)
12289 custom_subscreen[3].objects[i].d3=1;
12290 else
12291 custom_subscreen[3].objects[i].d3=0;
12292
12293 break;
12294 }
12295
12296 default:
12297 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12298 break;
12299 }
12300 }
12301
12302 custom_subscreen[3].ss_type=sstPASSIVE;
12303 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12304 break;
12305 }
12306 }
12307
12308
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 52 times.
65 for(int32_t i=0; i<4; ++i)
12309 {
12310 52 purge_blank_subscreen_objects(&custom_subscreen[i]);
12311 52 }
12312
12313 13 return 0;
12314 }
12315
12316 extern script_data *ffscripts[NUMSCRIPTFFC];
12317 extern script_data *itemscripts[NUMSCRIPTITEM];
12318 extern script_data *guyscripts[NUMSCRIPTGUYS];
12319 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12320 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12321 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12322 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12323 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12324 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12325 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12326 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12327 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12328 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12329 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12330
12331
12332
12333 62 int32_t readffscript(PACKFILE *f, zquestheader *Header, bool keepdata)
12334 {
12335 int32_t dummy;
12336 62 word s_version=0, s_cversion=0, zmeta_version=0;
12337 62 byte numscripts=0;
12338 62 numscripts=numscripts; //to avoid unused variables warnings
12339 int32_t ret;
12340
12341 //section version info
12342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(!p_igetw(&s_version,f,true))
12343 {
12344 return qe_invalid;
12345 }
12346
12347 62 FFCore.quest_format[vFFScript] = s_version;
12348
12349
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_cversion,f,true))
12350 {
12351 return qe_invalid;
12352 }
12353
12354
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if(s_version >= 18)
12355 {
12356
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&zmeta_version,f,true))
12357 {
12358 return qe_invalid;
12359 }
12360 3 }
12361
12362 //al_trace("Scripts version %d\n", s_version);
12363 //section size
12364
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&dummy,f,true))
12365 {
12366 return qe_invalid;
12367 }
12368
12369 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12370 62 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12371 62 temp_ffscript_version = s_version;
12372 //miscQdata *the_misc;
12373
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12374 62 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12375
12376 //finally... section data
12377
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 62 times.
31806 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12378 {
12379 31744 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12380
12381
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(ret != 0) return qe_invalid;
12382 31744 }
12383
12384 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12385 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12386 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12387 * there was a version bump a week before a change that broke stuff.
12388 */
12389
6/8
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 59 times.
62 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)) && keepdata)
12390 {
12391 59 set_bit(quest_rules,qr_SPRITE_JUMP_IS_TRUNCATED,1);
12392 59 }
12393
3/4
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 59 times.
62 if(s_version < 19 && keepdata)
12394 {
12395 59 set_bit(quest_rules,qr_FLUCTUATING_ENEMY_JUMP,1);
12396 59 }
12397
12398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(s_version > 1)
12399 {
12400
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12401 {
12402 15872 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12403
12404
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(ret != 0) return qe_invalid;
12405 15872 }
12406
12407
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12408 {
12409 15872 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12410
12411
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(ret != 0) return qe_invalid;
12412 15872 }
12413
12414
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12415 {
12416 15872 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12417
12418
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(ret != 0) return qe_invalid;
12419 15872 }
12420
12421
12422
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12423 {
12424 15872 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12425
12426
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(ret != 0) return qe_invalid;
12427 15872 }
12428
12429
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version > 16)
12430 {
12431
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 3 times.
27 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12432 {
12433 24 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12434
12435
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(ret != 0) return qe_invalid;
12436 24 }
12437 3 }
12438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 else if(s_version > 13)
12439 {
12440 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12441 {
12442 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12443
12444 if(ret != 0) return qe_invalid;
12445 }
12446
12447 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12448 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12449
12450 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12451 }
12452
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 else if(s_version > 4)
12453 {
12454
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 59 times.
295 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12455 {
12456 236 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12457
12458
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if(ret != 0) return qe_invalid;
12459 236 }
12460
12461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12462
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12463
12464
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12465
12466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12467
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12468
12469
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12470
12471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12472
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 delete globalscripts[GLOBAL_SCRIPT_F6];
12473
12474
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12475
12476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12477
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12478
12479
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12480 59 }
12481 else
12482 {
12483 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12484 {
12485 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12486
12487 if(ret != 0) return qe_invalid;
12488 }
12489
12490 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12491 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12492
12493 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12494
12495 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12496 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12497
12498 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12499
12500 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12501 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12502
12503 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12504
12505 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12506 delete globalscripts[GLOBAL_SCRIPT_F6];
12507
12508 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12509
12510 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12511 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12512
12513 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12514 }
12515
12516
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version > 10) //expanded the number of Player scripts to 5.
12517 {
12518
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 3 times.
18 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12519 {
12520 15 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12521
12522
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(ret != 0) return qe_invalid;
12523 15 }
12524 3 }
12525 else
12526 {
12527
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 59 times.
236 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12528 {
12529 177 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12530
12531
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if(ret != 0) return qe_invalid;
12532 177 }
12533
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(playerscripts[3] != NULL)
12534
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 delete playerscripts[3];
12535
12536
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 playerscripts[3] = new script_data();
12537
12538
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(playerscripts[4] != NULL)
12539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 delete playerscripts[4];
12540
12541
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 playerscripts[4] = new script_data();
12542 }
12543
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
62 if(s_version > 8 && s_version < 10)
12544 {
12545
12546 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12547 {
12548 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12549
12550 if(ret != 0) return qe_invalid;
12551 }
12552 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12553 {
12554 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12555
12556 if(ret != 0) return qe_invalid;
12557 }
12558
12559 }
12560
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if(s_version >= 10)
12561 {
12562
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12563 {
12564 768 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12565
12566
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(ret != 0) return qe_invalid;
12567 768 }
12568
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12569 {
12570 768 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12571
12572
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(ret != 0) return qe_invalid;
12573 768 }
12574
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12575 {
12576 768 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12577
12578
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(ret != 0) return qe_invalid;
12579 768 }
12580
12581 3 }
12582
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if(s_version >=12)
12583 {
12584
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12585 {
12586 768 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12587
12588
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(ret != 0) return qe_invalid;
12589 768 }
12590 3 }
12591
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if(s_version >=15)
12592 {
12593
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3 times.
1539 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12594 {
12595 1536 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12596
12597
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(ret != 0) return qe_invalid;
12598 1536 }
12599 3 }
12600
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if(s_version >19)
12601 {
12602 3 word numgenscripts = NUMSCRIPTSGENERIC;
12603
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&numgenscripts,f,true))
12604 {
12605 return qe_invalid;
12606 }
12607
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3 times.
1539 for(int32_t i = 0; i < numgenscripts; i++)
12608 {
12609 1536 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12610
12611
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(ret != 0) return qe_invalid;
12612 1536 }
12613 3 }
12614
12615 /*
12616 else //Is this trip really necessary?
12617 {
12618 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12619 {
12620
12621 ewpnscripts[i] = NULL;
12622 }
12623 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12624 {
12625 dmapscripts[i] = NULL;
12626 }
12627 }
12628 */
12629
12630 62 }
12631
12632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(s_version > 2)
12633 {
12634 int32_t bufsize;
12635 62 p_igetl(&bufsize, f, true);
12636 62 char * buf = new char[bufsize+1];
12637 62 pfread(buf, bufsize, f, true);
12638 62 buf[bufsize]=0;
12639
12640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata)
12641 62 zScript = string(buf);
12642
12643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 delete[] buf;
12644 word numffcbindings;
12645 62 p_igetw(&numffcbindings, f, true);
12646
12647
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 62 times.
505 for(int32_t i=0; i<numffcbindings; i++)
12648 {
12649 word id;
12650 443 p_igetw(&id, f, true);
12651 443 p_igetl(&bufsize, f, true);
12652 443 buf = new char[bufsize+1];
12653 443 pfread(buf, bufsize, f, true);
12654 443 buf[bufsize]=0;
12655
12656 //fix for buggy older saved quests -DD
12657
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 443 times.
443 if(keepdata && id < NUMSCRIPTFFC-1)
12658 443 ffcmap[id].scriptname = buf;
12659
12660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 delete[] buf;
12661 443 }
12662
12663 word numglobalbindings;
12664 62 p_igetw(&numglobalbindings, f, true);
12665
12666
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 62 times.
364 for(int32_t i=0; i<numglobalbindings; i++)
12667 {
12668 word id;
12669 302 p_igetw(&id, f, true);
12670 302 p_igetl(&bufsize, f, true);
12671 302 buf = new char[bufsize+1];
12672 302 pfread(buf, bufsize, f, true);
12673 302 buf[bufsize]=0;
12674
12675 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12676 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12677 // Ignore these. -DD
12678
4/6
✓ Branch 0 taken 302 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✓ Branch 5 taken 169 times.
302 if(keepdata && id >= 0 && id < NUMSCRIPTGLOBAL)
12679 {
12680 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12681
1/2
✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
169 if(strcmp(buf,"~Continue") == 0)
12682 {
12683 globalmap[id].scriptname = "";
12684
12685 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12686 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12687 }
12688 else
12689 {
12690 169 globalmap[id].scriptname = buf;
12691 }
12692 169 }
12693
12694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 302 times.
302 delete[] buf;
12695 302 }
12696
12697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(s_version > 3)
12698 {
12699 word numitembindings;
12700 62 p_igetw(&numitembindings, f, true);
12701
12702
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 62 times.
72 for(int32_t i=0; i<numitembindings; i++)
12703 {
12704 word id;
12705 10 p_igetw(&id, f, true);
12706 10 p_igetl(&bufsize, f, true);
12707 10 buf = new char[bufsize+1];
12708 10 pfread(buf, bufsize, f, true);
12709 10 buf[bufsize]=0;
12710
12711 //fix this too
12712
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(keepdata && id <NUMSCRIPTITEM-1)
12713 10 itemmap[id].scriptname = buf;
12714
12715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 delete[] buf;
12716 10 }
12717 62 }
12718 //(v9+)
12719
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if(s_version > 8)
12720 {
12721 //npc scripts
12722 word numnpcbindings;
12723 3 p_igetw(&numnpcbindings, f, true);
12724
12725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 for(int32_t i=0; i<numnpcbindings; i++)
12726 {
12727 word id;
12728 p_igetw(&id, f, true);
12729 p_igetl(&bufsize, f, true);
12730 buf = new char[bufsize+1];
12731 pfread(buf, bufsize, f, true);
12732 buf[bufsize]=0;
12733
12734 //fix this too
12735 if(keepdata && id <NUMSCRIPTGUYS-1)
12736 npcmap[id].scriptname = buf;
12737
12738 delete[] buf;
12739 }
12740 //lweapon
12741 word numlwpnbindings;
12742 3 p_igetw(&numlwpnbindings, f, true);
12743
12744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 for(int32_t i=0; i<numlwpnbindings; i++)
12745 {
12746 word id;
12747 p_igetw(&id, f, true);
12748 p_igetl(&bufsize, f, true);
12749 buf = new char[bufsize+1];
12750 pfread(buf, bufsize, f, true);
12751 buf[bufsize]=0;
12752
12753 //fix this too
12754 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12755 lwpnmap[id].scriptname = buf;
12756
12757 delete[] buf;
12758 }
12759 //eweapon
12760 word numewpnbindings;
12761 3 p_igetw(&numewpnbindings, f, true);
12762
12763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 for(int32_t i=0; i<numewpnbindings; i++)
12764 {
12765 word id;
12766 p_igetw(&id, f, true);
12767 p_igetl(&bufsize, f, true);
12768 buf = new char[bufsize+1];
12769 pfread(buf, bufsize, f, true);
12770 buf[bufsize]=0;
12771
12772 //fix this too
12773 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12774 ewpnmap[id].scriptname = buf;
12775
12776 delete[] buf;
12777 }
12778 //hero
12779 word numherobindings;
12780 3 p_igetw(&numherobindings, f, true);
12781
12782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 for(int32_t i=0; i<numherobindings; i++)
12783 {
12784 word id;
12785 p_igetw(&id, f, true);
12786 p_igetl(&bufsize, f, true);
12787 buf = new char[bufsize+1];
12788 pfread(buf, bufsize, f, true);
12789 buf[bufsize]=0;
12790
12791 //fix this too
12792 if(keepdata && id <NUMSCRIPTPLAYER-1)
12793 playermap[id].scriptname = buf;
12794
12795 delete[] buf;
12796 }
12797 //dmaps
12798 word numdmapbindings;
12799 3 p_igetw(&numdmapbindings, f, true);
12800
12801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 for(int32_t i=0; i<numdmapbindings; i++)
12802 {
12803 word id;
12804 p_igetw(&id, f, true);
12805 p_igetl(&bufsize, f, true);
12806 buf = new char[bufsize+1];
12807 pfread(buf, bufsize, f, true);
12808 buf[bufsize]=0;
12809
12810 //fix this too
12811 if(keepdata && id <NUMSCRIPTSDMAP-1)
12812 dmapmap[id].scriptname = buf;
12813
12814 delete[] buf;
12815 }
12816 //screen
12817 word numscreenbindings;
12818 3 p_igetw(&numscreenbindings, f, true);
12819
12820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 for(int32_t i=0; i<numscreenbindings; i++)
12821 {
12822 word id;
12823 p_igetw(&id, f, true);
12824 p_igetl(&bufsize, f, true);
12825 buf = new char[bufsize+1];
12826 pfread(buf, bufsize, f, true);
12827 buf[bufsize]=0;
12828
12829 //fix this too
12830 if(keepdata && id <NUMSCRIPTSDMAP-1)
12831 screenmap[id].scriptname = buf;
12832
12833 delete[] buf;
12834 }
12835 3 }
12836
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if(s_version > 11)
12837 {
12838 word numspritebindings;
12839 3 p_igetw(&numspritebindings, f, true);
12840
12841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 for(int32_t i=0; i<numspritebindings; i++)
12842 {
12843 word id;
12844 p_igetw(&id, f, true);
12845 p_igetl(&bufsize, f, true);
12846 buf = new char[bufsize+1];
12847 pfread(buf, bufsize, f, true);
12848 buf[bufsize]=0;
12849
12850 //fix this too
12851 if(keepdata && id <NUMSCRIPTSDMAP-1)
12852 itemspritemap[id].scriptname = buf;
12853
12854 delete[] buf;
12855 }
12856 3 }
12857
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if(s_version >= 15)
12858 {
12859 word numcombobindings;
12860 3 p_igetw(&numcombobindings, f, true);
12861
12862
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<numcombobindings; i++)
12863 {
12864 word id;
12865 1 p_igetw(&id, f, true);
12866 1 p_igetl(&bufsize, f, true);
12867 1 buf = new char[bufsize+1];
12868 1 pfread(buf, bufsize, f, true);
12869 1 buf[bufsize]=0;
12870
12871 //fix this too
12872
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(keepdata && id <NUMSCRIPTSCOMBODATA-1)
12873 1 comboscriptmap[id].scriptname = buf;
12874
12875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 delete[] buf;
12876 1 }
12877 3 }
12878
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if(s_version > 19)
12879 {
12880 word numgenericbindings;
12881 3 p_igetw(&numgenericbindings, f, true);
12882
12883
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<numgenericbindings; i++)
12884 {
12885 word id;
12886 1 p_igetw(&id, f, true);
12887 1 p_igetl(&bufsize, f, true);
12888 1 buf = new char[bufsize+1];
12889 1 pfread(buf, bufsize, f, true);
12890 1 buf[bufsize]=0;
12891
12892 //fix this too
12893
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(keepdata && id <NUMSCRIPTSGENERIC-1)
12894 1 genericmap[id].scriptname = buf;
12895
12896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 delete[] buf;
12897 1 }
12898 3 }
12899 62 }
12900
12901 62 return 0;
12902 62 }
12903
12904 62 void reset_scripts()
12905 {
12906 //OK, who spaced this? ;)
12907
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 62 times.
31806 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12908 {
12909
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31744 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31744 times.
31744 if(ffscripts[i]!=NULL) delete ffscripts[i];
12910 31744 }
12911
12912
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12913 {
12914
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15872 times.
15872 if(itemscripts[i]!=NULL) delete itemscripts[i];
12915 15872 }
12916
12917
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12918 {
12919
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15872 times.
15872 if(guyscripts[i]!=NULL) delete guyscripts[i];
12920 15872 }
12921
12922
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12923 {
12924
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15872 times.
15872 if(wpnscripts[i]!=NULL) delete wpnscripts[i];
12925 15872 }
12926
12927
12928
12929
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12930 {
12931
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15872 times.
15872 if(screenscripts[i]!=NULL) delete screenscripts[i];
12932 15872 }
12933
12934
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 62 times.
558 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12935 {
12936
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 496 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 496 times.
496 if(globalscripts[i]!=NULL) delete globalscripts[i];
12937 496 }
12938
12939
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 62 times.
372 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12940 {
12941
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 310 times.
310 if(playerscripts[i]!=NULL) delete playerscripts[i];
12942 310 }
12943
12944
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12945 {
12946
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15872 times.
15872 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
12947 15872 }
12948
12949
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12950 {
12951
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15872 times.
15872 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
12952 15872 }
12953
12954
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12955 {
12956
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15872 times.
15872 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
12957 15872 }
12958
12959
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12960 {
12961
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15872 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15872 times.
15872 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
12962 15872 }
12963
12964
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 62 times.
31806 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12965 {
12966
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31744 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31744 times.
31744 if(comboscripts[i]!=NULL) delete comboscripts[i];
12967 31744 }
12968
12969
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 62 times.
31806 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12970 {
12971
3/4
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 26112 times.
✓ Branch 2 taken 26112 times.
✗ Branch 3 not taken.
31744 if(genericscripts[i]!=NULL) delete genericscripts[i];
12972
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 genericscripts[i] = new script_data();
12973 31744 }
12974
12975
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 62 times.
31806 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12976 {
12977
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 ffscripts[i] = new script_data();
12978 31744 }
12979
12980
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12981 {
12982
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 itemscripts[i] = new script_data();
12983 15872 }
12984
12985
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12986 {
12987
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 guyscripts[i] = new script_data();
12988 15872 }
12989
12990
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12991 {
12992
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 wpnscripts[i] = new script_data();
12993 15872 }
12994
12995
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12996 {
12997
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 screenscripts[i] = new script_data();
12998 15872 }
12999
13000
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 62 times.
558 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13001 {
13002
1/2
✓ Branch 0 taken 496 times.
✗ Branch 1 not taken.
496 globalscripts[i] = new script_data();
13003 496 }
13004
13005
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 62 times.
372 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13006 {
13007
1/2
✓ Branch 0 taken 310 times.
✗ Branch 1 not taken.
310 playerscripts[i] = new script_data();
13008 310 }
13009
13010
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13011 {
13012
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 lwpnscripts[i] = new script_data();
13013 15872 }
13014
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13015 {
13016
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 ewpnscripts[i] = new script_data();
13017 15872 }
13018
13019
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13020 {
13021
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 dmapscripts[i] = new script_data();
13022 15872 }
13023
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13024 {
13025
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 itemspritescripts[i] = new script_data();
13026 15872 }
13027
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 62 times.
31806 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13028 {
13029
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 comboscripts[i] = new script_data();
13030 31744 }
13031 62 }
13032
13033 extern script_command command_list[];
13034 101828 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, bool keepdata, int32_t , word s_version, word , script_data **script, word zmeta_version)
13035 {
13036 //Please also update loadquest() when modifying this method -DD
13037 101828 char b33[34] = {0};
13038 101828 b33[33] = 0;
13039 101828 ffscript temp_script;
13040 101828 int32_t num_commands=1000;
13041
13042
1/2
✓ Branch 0 taken 101828 times.
✗ Branch 1 not taken.
101828 if(s_version>=2)
13043 {
13044
2/4
✓ Branch 0 taken 101828 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101828 times.
✗ Branch 3 not taken.
101828 if(!p_igetl(&num_commands,f,true))
13045 {
13046 return qe_invalid;
13047 }
13048 101828 }
13049
13050
1/2
✓ Branch 0 taken 101828 times.
✗ Branch 1 not taken.
101828 if(keepdata)
13051 {
13052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101828 times.
101828 if((*script) != NULL) //Surely we want to do this regardless of keepdata? //No, we don't -V
13053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101828 times.
101828 delete (*script);
13054
2/4
✓ Branch 0 taken 101828 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101828 times.
✗ Branch 3 not taken.
101828 (*script) = new script_data(num_commands);
13055 101828 }
13056
2/2
✓ Branch 0 taken 10791 times.
✓ Branch 1 taken 91037 times.
101828 if(s_version >= 16)
13057 {
13058
1/2
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
10791 zasm_meta temp_meta;
13059
13060
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_igetw(&(temp_meta.zasm_v),f,true))
13061 {
13062 return qe_invalid;
13063 }
13064
13065
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_igetw(&(temp_meta.meta_v),f,true))
13066 {
13067 return qe_invalid;
13068 }
13069
13070
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_igetw(&(temp_meta.ffscript_v),f,true))
13071 {
13072 return qe_invalid;
13073 }
13074
13075
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_getc(&(temp_meta.script_type),f,true))
13076 {
13077 return qe_invalid;
13078 }
13079
13080
2/2
✓ Branch 0 taken 86328 times.
✓ Branch 1 taken 10791 times.
97119 for(int32_t q = 0; q < 8; ++q)
13081 {
13082
2/2
✓ Branch 0 taken 28776 times.
✓ Branch 1 taken 57552 times.
86328 if(zmeta_version < 3)
13083 {
13084
2/2
✓ Branch 0 taken 28776 times.
✓ Branch 1 taken 949608 times.
978384 for(int32_t c = 0; c < 33; ++c)
13085 {
13086
2/4
✓ Branch 0 taken 949608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 949608 times.
✗ Branch 3 not taken.
949608 if(!p_getc(&(b33[c]),f,true))
13087 {
13088 return qe_invalid;
13089 }
13090 949608 }
13091
1/2
✓ Branch 0 taken 28776 times.
✗ Branch 1 not taken.
28776 temp_meta.run_idens[q].assign(b33);
13092 28776 }
13093 else
13094 {
13095
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getcstr(&temp_meta.run_idens[q],f,true))
13096 {
13097 return qe_invalid;
13098 }
13099 }
13100 86328 }
13101
13102
2/2
✓ Branch 0 taken 10791 times.
✓ Branch 1 taken 86328 times.
97119 for(int32_t q = 0; q < 8; ++q)
13103 {
13104
2/4
✓ Branch 0 taken 86328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86328 times.
✗ Branch 3 not taken.
86328 if(!p_getc(&(temp_meta.run_types[q]),f,true))
13105 {
13106 return qe_invalid;
13107 }
13108 86328 }
13109
13110
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_getc(&(temp_meta.flags),f,true))
13111 {
13112 return qe_invalid;
13113 }
13114
13115
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_igetw(&(temp_meta.compiler_v1),f,true))
13116 {
13117 return qe_invalid;
13118 }
13119
13120
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_igetw(&(temp_meta.compiler_v2),f,true))
13121 {
13122 return qe_invalid;
13123 }
13124
13125
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_igetw(&(temp_meta.compiler_v3),f,true))
13126 {
13127 return qe_invalid;
13128 }
13129
13130
2/4
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10791 times.
✗ Branch 3 not taken.
10791 if(!p_igetw(&(temp_meta.compiler_v4),f,true))
13131 {
13132 return qe_invalid;
13133 }
13134
13135
2/2
✓ Branch 0 taken 3597 times.
✓ Branch 1 taken 7194 times.
10791 if(zmeta_version == 2)
13136 {
13137
2/2
✓ Branch 0 taken 3597 times.
✓ Branch 1 taken 118701 times.
122298 for(int32_t c = 0; c < 33; ++c)
13138 {
13139
2/4
✓ Branch 0 taken 118701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 118701 times.
✗ Branch 3 not taken.
118701 if(!p_getc(&b33[c],f,true))
13140 {
13141 return qe_invalid;
13142 }
13143 118701 }
13144
1/2
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
3597 temp_meta.script_name.assign(b33);
13145
13146
2/2
✓ Branch 0 taken 3597 times.
✓ Branch 1 taken 118701 times.
122298 for(int32_t c = 0; c < 33; ++c)
13147 {
13148
2/4
✓ Branch 0 taken 118701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 118701 times.
✗ Branch 3 not taken.
118701 if(!p_getc(&b33[c],f,true))
13149 {
13150 return qe_invalid;
13151 }
13152 118701 }
13153
1/2
✓ Branch 0 taken 3597 times.
✗ Branch 1 not taken.
3597 temp_meta.author.assign(b33);
13154 3597 }
13155
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 else if(zmeta_version > 2)
13156 {
13157
2/4
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7194 times.
✗ Branch 3 not taken.
7194 if(!p_getcstr(&temp_meta.script_name,f,true))
13158 return qe_invalid;
13159
2/4
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7194 times.
✗ Branch 3 not taken.
7194 if(!p_getcstr(&temp_meta.author,f,true))
13160 return qe_invalid;
13161 7194 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13162
2/2
✓ Branch 0 taken 71940 times.
✓ Branch 1 taken 7194 times.
79134 for(auto q = 0; q < num_meta_attrib; ++q)
13163 {
13164
2/4
✓ Branch 0 taken 71940 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71940 times.
✗ Branch 3 not taken.
71940 if(!p_getcstr(&temp_meta.attributes[q],f,true))
13165 return qe_invalid;
13166
2/4
✓ Branch 0 taken 71940 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71940 times.
✗ Branch 3 not taken.
71940 if(!p_getwstr(&temp_meta.attributes_help[q],f,true))
13167 return qe_invalid;
13168 71940 }
13169
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13170 {
13171
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getcstr(&temp_meta.attribytes[q],f,true))
13172 return qe_invalid;
13173
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getwstr(&temp_meta.attribytes_help[q],f,true))
13174 return qe_invalid;
13175 57552 }
13176
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13177 {
13178
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getcstr(&temp_meta.attrishorts[q],f,true))
13179 return qe_invalid;
13180
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getwstr(&temp_meta.attrishorts_help[q],f,true))
13181 return qe_invalid;
13182 57552 }
13183
2/2
✓ Branch 0 taken 115104 times.
✓ Branch 1 taken 7194 times.
122298 for(auto q = 0; q < 16; ++q)
13184 {
13185
2/4
✓ Branch 0 taken 115104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115104 times.
✗ Branch 3 not taken.
115104 if(!p_getcstr(&temp_meta.usrflags[q],f,true))
13186 return qe_invalid;
13187
2/4
✓ Branch 0 taken 115104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115104 times.
✗ Branch 3 not taken.
115104 if(!p_getwstr(&temp_meta.usrflags_help[q],f,true))
13188 return qe_invalid;
13189 115104 }
13190 7194 }
13191
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 3597 times.
10791 if(zmeta_version > 3)
13192 {
13193
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13194 {
13195
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getcstr(&temp_meta.initd[q],f,true))
13196 return qe_invalid;
13197
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getwstr(&temp_meta.initd_help[q],f,true))
13198 return qe_invalid;
13199 57552 }
13200
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13201 {
13202
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getc(&temp_meta.initd_type[q],f,true))
13203 return qe_invalid;
13204 57552 }
13205 7194 }
13206 else
13207 {
13208
2/2
✓ Branch 0 taken 28776 times.
✓ Branch 1 taken 3597 times.
32373 for(auto q = 0; q < 8; ++q)
13209 {
13210
1/2
✓ Branch 0 taken 28776 times.
✗ Branch 1 not taken.
28776 temp_meta.initd[q] = temp_meta.run_idens[q];
13211 28776 }
13212 }
13213
13214
1/2
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
10791 if(keepdata)
13215
1/2
✓ Branch 0 taken 10791 times.
✗ Branch 1 not taken.
10791 (*script)->meta = temp_meta;
13216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10791 times.
10791 }
13217
13218
1/2
✓ Branch 0 taken 101828 times.
✗ Branch 1 not taken.
101828 temp_script.clear();
13219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2320657 times.
2320657 for(int32_t j=0; j<num_commands; j++)
13220 {
13221
2/4
✓ Branch 0 taken 2320657 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2320657 times.
✗ Branch 3 not taken.
2320657 if(!p_igetw(&(temp_script.command),f,true))
13222 {
13223 return qe_invalid;
13224 }
13225
13226
2/2
✓ Branch 0 taken 2218829 times.
✓ Branch 1 taken 101828 times.
2320657 if(temp_script.command == 0xFFFF)
13227 {
13228
1/2
✓ Branch 0 taken 101828 times.
✗ Branch 1 not taken.
101828 if(keepdata)
13229
1/2
✓ Branch 0 taken 101828 times.
✗ Branch 1 not taken.
101828 (*script)->zasm[j].clear();
13230 101828 break;
13231 }
13232 else
13233 {
13234
2/4
✓ Branch 0 taken 2218829 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2218829 times.
✗ Branch 3 not taken.
2218829 if(!p_igetl(&(temp_script.arg1),f,keepdata))
13235 {
13236 return qe_invalid;
13237 }
13238
13239
2/4
✓ Branch 0 taken 2218829 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2218829 times.
✗ Branch 3 not taken.
2218829 if(!p_igetl(&(temp_script.arg2),f,keepdata))
13240 {
13241 return qe_invalid;
13242 }
13243
13244
2/2
✓ Branch 0 taken 1249 times.
✓ Branch 1 taken 2217580 times.
2218829 if(s_version >= 21)
13245 {
13246 1249 uint32_t sz = 0;
13247
2/4
✓ Branch 0 taken 1249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1249 times.
✗ Branch 3 not taken.
1249 if(!p_igetl(&sz,f,keepdata))
13248 {
13249 return qe_invalid;
13250 }
13251
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1244 times.
1249 if(sz) //string found
13252 {
13253
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 temp_script.strptr = new std::string();
13254 char dummy;
13255
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 5 times.
64 for(size_t q = 0; q < sz; ++q)
13256 {
13257
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_getc(&dummy,f,keepdata))
13258 {
13259 return qe_invalid;
13260 }
13261
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 temp_script.strptr->push_back(dummy);
13262 59 }
13263 5 }
13264
2/4
✓ Branch 0 taken 1249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1249 times.
✗ Branch 3 not taken.
1249 if(!p_igetl(&sz,f,keepdata))
13265 {
13266 return qe_invalid;
13267 }
13268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1249 times.
1249 if(sz) //vector found
13269 {
13270 temp_script.vecptr = new std::vector<int32_t>();
13271 int32_t dummy;
13272 for(size_t q = 0; q < sz; ++q)
13273 {
13274 if(!p_igetl(&dummy,f,keepdata))
13275 {
13276 return qe_invalid;
13277 }
13278 temp_script.vecptr->push_back(dummy);
13279 }
13280 }
13281 1249 }
13282
13283
1/2
✓ Branch 0 taken 2218829 times.
✗ Branch 1 not taken.
2218829 if(keepdata)
13284 {
13285
1/2
✓ Branch 0 taken 2218829 times.
✗ Branch 1 not taken.
2218829 temp_script.give((*script)->zasm[j]);
13286 2218829 }
13287 }
13288
1/2
✓ Branch 0 taken 2218829 times.
✗ Branch 1 not taken.
2218829 temp_script.clear();
13289 2218829 }
13290
13291 101828 return 0;
13292 101828 }
13293
13294 extern SAMPLE customsfxdata[WAV_COUNT];
13295 extern uint8_t customsfxflag[WAV_COUNT>>3];
13296 extern int32_t sfxdat;
13297 extern DATAFILE *sfxdata;
13298 const char *old_sfx_string[Z35] =
13299 {
13300 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13301 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13302 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13303 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13304 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13305 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13306 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13307 "Din's Fire", "Enemy falls from ceiling", "Farore's Wind", "Fireball", "Tall Grass slashed",
13308 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13309 "Nayru's Love shield", "Nayru's Love shield 2", "Push block", "Rock", "Spell rocket down",
13310 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13311 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13312 };
13313 char *sfx_string[WAV_COUNT];
13314
13315 62 int32_t readsfx(PACKFILE *f, zquestheader *Header, bool keepdata)
13316 {
13317 //these are here to bypass compiler warnings about unused arguments
13318 62 Header=Header;
13319
13320 int32_t dummy;
13321 62 word s_version=0, s_cversion=0;
13322 //int32_t ret;
13323 SAMPLE temp_sample;
13324 62 temp_sample.loop_start=0;
13325 62 temp_sample.loop_end=0;
13326 62 temp_sample.param=0;
13327
13328 //section version info
13329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(!p_igetw(&s_version,f,true))
13330 {
13331 return qe_invalid;
13332 }
13333
13334 62 FFCore.quest_format[vSFX] = s_version;
13335
13336 //al_trace("SFX version %d\n", s_version);
13337
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_cversion,f,true))
13338 {
13339 return qe_invalid;
13340 }
13341
13342 //section size
13343
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&dummy,f,true))
13344 {
13345 return qe_invalid;
13346 }
13347
13348 /* HIGHLY UNORTHODOX UPDATING THING, by L
13349 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13350 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13351 * changing from 1 to 2.
13352 */
13353
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 if(s_version < 2 && keepdata)
13354 set_bit(quest_rules,qr_GOTOLESSNOTEQUAL,1);
13355
13356 /* End highly unorthodox updating thing */
13357
13358 62 int32_t wavcount = WAV_COUNT;
13359
13360
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version < 6)
13361 wavcount = 128;
13362
13363 uint8_t tempflag[WAV_COUNT>>3];
13364
13365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(s_version < 4)
13366 {
13367 memset(tempflag, 0xFF, WAV_COUNT>>3);
13368 }
13369 else
13370 {
13371
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version < 6)
13372 memset(tempflag, 0, WAV_COUNT>>3);
13373
13374
2/2
✓ Branch 0 taken 1984 times.
✓ Branch 1 taken 62 times.
2046 for(int32_t i=0; i<(wavcount>>3); i++)
13375 {
13376 1984 p_getc(&tempflag[i], f, true);
13377 1984 }
13378
13379 }
13380
13381
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version>4)
13382 {
13383
2/2
✓ Branch 0 taken 15810 times.
✓ Branch 1 taken 62 times.
15872 for(int32_t i=1; i<WAV_COUNT; i++)
13384 {
13385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15810 times.
15810 if(keepdata)
13386 {
13387 15810 sprintf(sfx_string[i],"s%03d",i);
13388
13389
2/2
✓ Branch 0 taken 12090 times.
✓ Branch 1 taken 3720 times.
15810 if((i<Z35))
13390 3720 strcpy(sfx_string[i], old_sfx_string[i-1]);
13391 15810 }
13392
13393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15810 times.
15810 if(i>=wavcount)
13394 continue;
13395
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 15550 times.
15810 if(get_bit(tempflag, i-1))
13396 {
13397 char tempname[36];
13398
13399
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!pfread(tempname, 36, f, keepdata))
13400 {
13401 return qe_invalid;
13402 }
13403
13404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 260 times.
260 if(keepdata)
13405 {
13406 260 strcpy(sfx_string[i], tempname);
13407 260 sfx_string[i][35] = 0; //Force NULL Termination
13408 260 }
13409 260 }
13410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15550 times.
15550 else if(keepdata)
13411 {
13412 15550 sprintf(sfx_string[i],"s%03d",i);
13413
13414
2/2
✓ Branch 0 taken 12020 times.
✓ Branch 1 taken 3530 times.
15550 if(i<Z35)
13415 3530 strcpy(sfx_string[i], old_sfx_string[i-1]);
13416 15550 sfx_string[i][35] = 0; //Force NULL Termination
13417 15550 }
13418 15810 }
13419 62 }
13420 else
13421 {
13422 if(keepdata)
13423 {
13424 for(int32_t i=1; i<WAV_COUNT; i++)
13425 {
13426 sprintf(sfx_string[i],"s%03d",i);
13427
13428 if(i<Z35)
13429 strcpy(sfx_string[i], old_sfx_string[i-1]);
13430 }
13431 }
13432 }
13433
13434 //finally... section data
13435
2/2
✓ Branch 0 taken 15810 times.
✓ Branch 1 taken 62 times.
15872 for(int32_t i=1; i<wavcount; i++)
13436 {
13437
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 15550 times.
15810 if(get_bit(tempflag, i-1))
13438 {
13439
13440
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!p_igetl(&dummy,f,true))
13441 {
13442 return qe_invalid;
13443 }
13444
13445 260 (temp_sample.bits) = dummy;
13446
13447
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!p_igetl(&dummy,f,true))
13448 {
13449 return qe_invalid;
13450 }
13451
13452 260 (temp_sample.stereo) = dummy;
13453
13454
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!p_igetl(&dummy,f,keepdata))
13455 {
13456 return qe_invalid;
13457 }
13458
13459 260 (temp_sample.freq) = dummy;
13460
13461
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!p_igetl(&dummy,f,keepdata))
13462 {
13463 return qe_invalid;
13464 }
13465
13466 260 (temp_sample.priority) = dummy;
13467
13468
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!p_igetl(&(temp_sample.len),f,true))
13469 {
13470 return qe_invalid;
13471 }
13472
13473
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!p_igetl(&(temp_sample.loop_start),f,keepdata))
13474 {
13475 return qe_invalid;
13476 }
13477
13478
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!p_igetl(&(temp_sample.loop_end),f,keepdata))
13479 {
13480 return qe_invalid;
13481 }
13482
13483
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(!p_igetl(&(temp_sample.param),f,keepdata))
13484 {
13485 return qe_invalid;
13486 }
13487
13488 // al_trace("F%i: L%i\n",i,temp_sample.len);
13489 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13490 260 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13491 260 temp_sample.data = calloc(len,1);
13492
13493
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(s_version < 3)
13494 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13495
13496 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 260 times.
260 if(s_version < 2)
13498 {
13499 if(!pfread(temp_sample.data, len,f,keepdata))
13500 {
13501 return qe_invalid;
13502 }
13503 }
13504 else
13505 {
13506 //re-endianfy the data
13507 260 int32_t wordstoread = len / sizeof(word);
13508
13509
2/2
✓ Branch 0 taken 6086254 times.
✓ Branch 1 taken 260 times.
6086514 for(int32_t j=0; j<wordstoread; j++)
13510 {
13511 word temp;
13512
13513
1/2
✓ Branch 0 taken 6086254 times.
✗ Branch 1 not taken.
6086254 if(!p_igetw(&temp, f, keepdata))
13514 {
13515 return qe_invalid;
13516 }
13517
13518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6086254 times.
6086254 if(keepdata)
13519 6086254 ((word *)temp_sample.data)[j] = temp;
13520 6086254 }
13521 }
13522 260 }
13523
2/2
✓ Branch 0 taken 3530 times.
✓ Branch 1 taken 12020 times.
15550 else if(i < Z35)
13524 {
13525 3530 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13526 3530 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13527 3530 set_bit(tempflag, i-1, 1);
13528 3530 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13529 3530 temp_sample.data = calloc(len,1);
13530 3530 memcpy(temp_sample.data, datsamp->data, len);
13531 3530 }
13532 12020 else continue;
13533
13534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3790 times.
3790 if(keepdata)
13535 {
13536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3790 times.
3790 if(customsfxdata[i].data!=NULL)
13537 {
13538 // delete [] customsfxdata[i].data;
13539 3790 free(customsfxdata[i].data);
13540 3790 }
13541
13542 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13543 3790 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13544 3790 customsfxdata[i].data = calloc(len2,1);
13545 3790 customsfxdata[i].bits = temp_sample.bits;
13546 3790 customsfxdata[i].stereo = temp_sample.stereo;
13547 3790 customsfxdata[i].freq = temp_sample.freq;
13548 3790 customsfxdata[i].priority = temp_sample.priority;
13549 3790 customsfxdata[i].len = temp_sample.len;
13550 3790 customsfxdata[i].loop_start = temp_sample.loop_start;
13551 3790 customsfxdata[i].loop_end = temp_sample.loop_end;
13552 3790 customsfxdata[i].param = temp_sample.param;
13553 3790 int32_t cpylen = len2;
13554
13555
1/2
✓ Branch 0 taken 3790 times.
✗ Branch 1 not taken.
3790 if(s_version<3)
13556 {
13557 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13558 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13559 }
13560
13561 3790 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13562 3790 }
13563
13564 3790 free(temp_sample.data);
13565 3790 }
13566
13567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata)
13568 62 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13569
13570 62 sfxdat=0;
13571 62 return 0;
13572 62 }
13573
13574 62 void setupsfx()
13575 {
13576
2/2
✓ Branch 0 taken 15810 times.
✓ Branch 1 taken 62 times.
15872 for(int32_t i=1; i<WAV_COUNT; i++)
13577 {
13578 15810 sprintf(sfx_string[i],"s%03d",i);
13579
13580
2/2
✓ Branch 0 taken 12090 times.
✓ Branch 1 taken 3720 times.
15810 if(i<Z35)
13581 {
13582 3720 strcpy(sfx_string[i], old_sfx_string[i-1]);
13583 3720 }
13584
13585 15810 memset(customsfxflag, 0, WAV_COUNT>>3);
13586
13587 15810 int32_t j=i;
13588
13589
2/2
✓ Branch 0 taken 3782 times.
✓ Branch 1 taken 12028 times.
15810 if(i>Z35)
13590 {
13591 12028 i=Z35;
13592 12028 }
13593
13594 15810 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13595
13596
2/2
✓ Branch 0 taken 2805 times.
✓ Branch 1 taken 13005 times.
15810 if(customsfxdata[j].data!=NULL)
13597 {
13598 // delete [] customsfxdata[j].data;
13599 13005 free(customsfxdata[j].data);
13600 13005 }
13601
13602 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13603 15810 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13604 15810 customsfxdata[j].bits = temp_sample->bits;
13605 15810 customsfxdata[j].stereo = temp_sample->stereo;
13606 15810 customsfxdata[j].freq = temp_sample->freq;
13607 15810 customsfxdata[j].priority = temp_sample->priority;
13608 15810 customsfxdata[j].len = temp_sample->len;
13609 15810 customsfxdata[j].loop_start = temp_sample->loop_start;
13610 15810 customsfxdata[j].loop_end = temp_sample->loop_end;
13611 15810 customsfxdata[j].param = temp_sample->param;
13612 15810 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13613 15810 i=j;
13614 15810 }
13615 62 }
13616
13617 extern char *guy_string[eMAXGUYS];
13618 extern const char *old_guy_string[OLDMAXGUYS];
13619
13620 62 int32_t readguys(PACKFILE *f, zquestheader *Header, bool keepdata)
13621 {
13622 dword dummy;
13623 word guy_cversion;
13624 62 word guyversion=0;
13625
13626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(Header->zelda_version >= 0x193)
13627 {
13628 //section version info
13629
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&guyversion,f,true))
13630 {
13631 return qe_invalid;
13632 }
13633
13634 62 FFCore.quest_format[vGuys] = guyversion;
13635
13636 //al_trace("Guys version %d\n", guyversion);
13637
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&guy_cversion,f,true))
13638 {
13639 return qe_invalid;
13640 }
13641 62 al_trace("Guy CVersion is: %d\n", guy_cversion);
13642 //section size
13643
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&dummy,f,true))
13644 {
13645 return qe_invalid;
13646 }
13647 62 }
13648
13649
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(guyversion > 3)
13650 {
13651
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 62 times.
31806 for(int32_t i=0; i<MAXGUYS; i++)
13652 {
13653 char tempname[64];
13654
13655 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13656 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13657
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31744 if(guyversion < 23 && i >= OLDBETAMAXGUYS && keepdata)
13658 {
13659 memset(tempname, 0, sizeof(char)*64);
13660 sprintf(tempname, "e%03d", i);
13661 strcpy(guy_string[i], tempname);
13662
13663 continue;
13664 }
13665
13666
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!pfread(tempname, 64, f, keepdata))
13667 {
13668 return qe_invalid;
13669 }
13670
13671 // Don't retain names of uneditable enemy entries!
13672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31744 times.
31744 if(keepdata)
13673 {
13674 // for version upgrade to 2.5
13675
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31744 if(guyversion < 23 && i >= 177)
13676 {
13677 // some of the older builds have names such as 'zz123',
13678 // (this order gets messed up with some eXXX and some zzXXX)
13679 // so let's update to the newer naming convection. -Gleeok
13680 char tmpbuf[64];
13681 memset(tmpbuf, 0, sizeof(char)*64);
13682 sprintf(tmpbuf, "zz%03d", i);
13683
13684 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13685 {
13686 memset(tempname, 0, sizeof(char)*64);
13687 sprintf(tempname, "e%03d", i);
13688 }
13689 }
13690
13691
6/6
✓ Branch 0 taken 10974 times.
✓ Branch 1 taken 20770 times.
✓ Branch 2 taken 10416 times.
✓ Branch 3 taken 558 times.
✓ Branch 4 taken 8218 times.
✓ Branch 5 taken 2198 times.
31744 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13692 {
13693 29546 strcpy(guy_string[i], tempname);
13694 29546 }
13695 else
13696 {
13697 2198 strcpy(guy_string[i],old_guy_string[i]);
13698 }
13699 31744 }
13700 31744 }
13701 62 }
13702 else
13703 {
13704 if(keepdata)
13705 {
13706 for(int32_t i=0; i<eMAXGUYS; i++)
13707 {
13708 sprintf(guy_string[i],"zz%03d",i);
13709 }
13710
13711 for(int32_t i=0; i<OLDMAXGUYS; i++)
13712 {
13713 strcpy(guy_string[i],old_guy_string[i]);
13714 }
13715 }
13716 }
13717
13718
13719 //finally... section data
13720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata)
13721 {
13722 62 init_guys(guyversion); //using default data for now...
13723
13724 // Goriya guy fix
13725
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13726 {
13727 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13728 {
13729 guysbuf[gGORIYA].tile=130;
13730 guysbuf[gGORIYA].e_tile=130;
13731 }
13732 }
13733 62 }
13734
13735
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(Header->zelda_version < 0x193)
13736 {
13737 if(get_bit(deprecated_rules,46))
13738 {
13739 guysbuf[eDODONGO].cset=14;
13740 guysbuf[eDODONGO].bosspal=spDIG;
13741 }
13742 }
13743 // Not sure when this first changed, but it's necessary for 2.10, at least
13744 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13745 //2.10 Fixes
13746
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13747 {
13748 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13749 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13750 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13751 guysbuf[eCENT1].misc3 = 1;
13752 guysbuf[eCENT2].misc3 = 1;
13753 }
13754
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13755 {
13756 62 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13757 62 }
13758
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(Header->zelda_version <= 0x210)
13759 {
13760 guysbuf[eGLEEOK1F].misc6 = 16;
13761 guysbuf[eGLEEOK2F].misc6 = 16;
13762 guysbuf[eGLEEOK3F].misc6 = 16;
13763 guysbuf[eGLEEOK4F].misc6 = 16;
13764
13765 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13766 guysbuf[eBATROBE].misc4 = 1;
13767 //guysbuf[eSUMMONER].misc4 = 1;
13768 guysbuf[eWWIZ].misc4 = 1;
13769 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13770 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13771 }
13772
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(Header->zelda_version == 0x190)
13773 {
13774 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13775 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13776 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13777 }
13778
13779 // The versions here may not be correct
13780 // zelda_version>=0x211 handled at guyversion<24
13781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(Header->zelda_version <= 0x190)
13782 {
13783 guysbuf[eCENT1].misc3 = 0;
13784 guysbuf[eCENT2].misc3 = 0;
13785 guysbuf[eMOLDORM].misc2 = 0;
13786 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13787 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13788 }
13789
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 else if(Header->zelda_version <= 0x210)
13790 {
13791 guysbuf[eCENT1].misc3 = 1;
13792 guysbuf[eCENT2].misc3 = 1;
13793 guysbuf[eMOLDORM].misc2 = 0;
13794 }
13795
13796
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13797 {
13798 guysbuf[eKEESE1].misc16 = 120;
13799 guysbuf[eKEESE2].misc16 = 120;
13800 guysbuf[eKEESE3].misc16 = 120;
13801 guysbuf[eKEESETRIB].misc16 = 120;
13802 guysbuf[eKEESE1].misc17 = 16;
13803 guysbuf[eKEESE2].misc17 = 16;
13804 guysbuf[eKEESE3].misc17 = 16;
13805 guysbuf[eKEESETRIB].misc17 = 16;
13806
13807 guysbuf[ePEAHAT].misc16 = 80;
13808 guysbuf[ePEAHAT].misc17 = 16;
13809
13810 guysbuf[eGHINI2].misc16 = 120;
13811 guysbuf[eGHINI2].misc17 = 10;
13812
13813 }
13814
13815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(guyversion<=2)
13816 {
13817 return readherosprites2(f, guyversion==2?0:-1, 0, keepdata);
13818 }
13819
13820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(guyversion > 3)
13821 {
13822 guydata tempguy;
13823
13824
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 62 times.
31806 for(int32_t i=0; i<MAXGUYS; i++)
13825 {
13826
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31744 if(guyversion < 23 && keepdata) // May 2012 : 512 max enemies
13827 {
13828 if(i >= OLDBETAMAXGUYS)
13829 {
13830 memset(&guysbuf[i], 0, sizeof(guydata));
13831 continue;
13832 }
13833 }
13834
13835 31744 memset(&tempguy, 0, sizeof(guydata));
13836
13837
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetl(&(tempguy.flags),f,keepdata))
13838 {
13839 return qe_invalid;
13840 }
13841
13842
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetl(&(tempguy.flags2),f,keepdata))
13843 {
13844 return qe_invalid;
13845 }
13846
13847
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if ( guyversion >= 36 ) //expanded tiles
13848 {
13849
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.tile),f,keepdata))
13850 {
13851 return qe_invalid;
13852 }
13853 1536 }
13854 else
13855 {
13856
1/2
✓ Branch 0 taken 30208 times.
✗ Branch 1 not taken.
30208 if(!p_igetw(&(tempguy.tile),f,keepdata))
13857 {
13858 return qe_invalid;
13859 }
13860 }
13861
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&(tempguy.width),f,keepdata))
13862 {
13863 return qe_invalid;
13864 }
13865
13866
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&(tempguy.height),f,keepdata))
13867 {
13868 return qe_invalid;
13869 }
13870
13871
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if ( guyversion >= 36 ) //expanded tiles
13872 {
13873
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.s_tile),f,keepdata))
13874 {
13875 return qe_invalid;
13876 }
13877 1536 }
13878 else
13879 {
13880
1/2
✓ Branch 0 taken 30208 times.
✗ Branch 1 not taken.
30208 if(!p_igetw(&(tempguy.s_tile),f,keepdata))
13881 {
13882 return qe_invalid;
13883 }
13884 }
13885
13886
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&(tempguy.s_width),f,keepdata))
13887 {
13888 return qe_invalid;
13889 }
13890
13891
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&(tempguy.s_height),f,keepdata))
13892 {
13893 return qe_invalid;
13894 }
13895
13896
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if ( guyversion >= 36 ) //expanded tiles
13897 {
13898
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.e_tile),f,keepdata))
13899 {
13900 return qe_invalid;
13901 }
13902 1536 }
13903 else
13904 {
13905
1/2
✓ Branch 0 taken 30208 times.
✗ Branch 1 not taken.
30208 if(!p_igetw(&(tempguy.e_tile),f,keepdata))
13906 {
13907 return qe_invalid;
13908 }
13909 }
13910
13911
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&(tempguy.e_width),f,keepdata))
13912 {
13913 return qe_invalid;
13914 }
13915
13916
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&(tempguy.e_height),f,keepdata))
13917 {
13918 return qe_invalid;
13919 }
13920
13921
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.hp),f,keepdata))
13922 {
13923 return qe_invalid;
13924 }
13925
13926
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.family),f,keepdata))
13927 {
13928 return qe_invalid;
13929 }
13930
13931
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 31744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
31744 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13932 {
13933 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13934 {
13935 tempguy.s_tile=tempguy.e_tile+120;
13936 tempguy.s_width=tempguy.e_width;
13937 tempguy.s_height=tempguy.e_height;
13938 }
13939 else tempguy.s_tile=860;
13940 }
13941
13942
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.cset),f,keepdata))
13943 {
13944 return qe_invalid;
13945 }
13946
13947
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.anim),f,keepdata))
13948 {
13949 return qe_invalid;
13950 }
13951
13952
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.e_anim),f,keepdata))
13953 {
13954 return qe_invalid;
13955 }
13956
13957
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.frate),f,keepdata))
13958 {
13959 return qe_invalid;
13960 }
13961
13962
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.e_frate),f,keepdata))
13963 {
13964 return qe_invalid;
13965 }
13966
13967
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion < 13) // April 2009
13968 {
13969 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13970 {
13971 tempguy.frate *= 2;
13972 tempguy.e_frate *= 2;
13973 }
13974 }
13975
13976
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion < 14) // May 1 2009
13977 {
13978 if(tempguy.anim==a2FRMSLOW)
13979 {
13980 tempguy.anim=a2FRM;
13981 tempguy.frate *= 2;
13982 }
13983
13984 if(tempguy.e_anim==a2FRMSLOW)
13985 {
13986 tempguy.e_anim=a2FRM;
13987 tempguy.e_frate *= 2;
13988 }
13989
13990 if(tempguy.anim==aFLIPSLOW)
13991 {
13992 tempguy.anim=aFLIP;
13993 tempguy.frate *= 2;
13994 }
13995
13996 if(tempguy.e_anim==aFLIPSLOW)
13997 {
13998 tempguy.e_anim=aFLIP;
13999 tempguy.e_frate *= 2;
14000 }
14001
14002 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14003
14004 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14005
14006 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14007 {
14008 tempguy.anim=a4FRM4DIR;
14009 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14010 }
14011
14012 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14013 {
14014 tempguy.e_anim=a4FRM4DIR;
14015 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14016 }
14017 }
14018
14019
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.dp),f,keepdata))
14020 {
14021 return qe_invalid;
14022 }
14023
14024 //correction for guy fire
14025
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion < 6)
14026 {
14027 if(i == gFIRE)
14028 tempguy.dp = 2;
14029 }
14030
14031
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.wdp),f,keepdata))
14032 {
14033 return qe_invalid;
14034 }
14035
14036
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.weapon),f,keepdata))
14037 {
14038 return qe_invalid;
14039 }
14040
14041 //correction for bosses using triple, "rising" fireballs
14042
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion < 5)
14043 {
14044 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14045 i == eGOHMA3 || i == eGOHMA4)
14046 {
14047 if(tempguy.weapon == ewFireball)
14048 tempguy.weapon = ewFireball2;
14049 }
14050 }
14051
14052
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.rate),f,keepdata))
14053 {
14054 return qe_invalid;
14055 }
14056
14057
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.hrate),f,keepdata))
14058 {
14059 return qe_invalid;
14060 }
14061
14062
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.step),f,keepdata))
14063 {
14064 return qe_invalid;
14065 }
14066
14067 // HIGHLY UNORTHODOX UPDATING THING, part 2
14068
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31744 if(fixpolsvoice && tempguy.family==eePOLSV)
14069 {
14070 tempguy.step /= 2;
14071 }
14072
14073
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.homing),f,keepdata))
14074 {
14075 return qe_invalid;
14076 }
14077
14078
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.grumble),f,keepdata))
14079 {
14080 return qe_invalid;
14081 }
14082
14083
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.item_set),f,keepdata))
14084 {
14085 return qe_invalid;
14086 }
14087
14088
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14089 {
14090
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetl(&(tempguy.misc1),f,keepdata))
14091 {
14092 return qe_invalid;
14093 }
14094
14095
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetl(&(tempguy.misc2),f,keepdata))
14096 {
14097 return qe_invalid;
14098 }
14099
14100
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetl(&(tempguy.misc3),f,keepdata))
14101 {
14102 return qe_invalid;
14103 }
14104
14105
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetl(&(tempguy.misc4),f,keepdata))
14106 {
14107 return qe_invalid;
14108 }
14109
14110
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetl(&(tempguy.misc5),f,keepdata))
14111 {
14112 return qe_invalid;
14113 }
14114
14115
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetl(&(tempguy.misc6),f,keepdata))
14116 {
14117 return qe_invalid;
14118 }
14119
14120
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetl(&(tempguy.misc7),f,keepdata))
14121 {
14122 return qe_invalid;
14123 }
14124
14125
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetl(&(tempguy.misc8),f,keepdata))
14126 {
14127 return qe_invalid;
14128 }
14129
14130
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetl(&(tempguy.misc9),f,keepdata))
14131 {
14132 return qe_invalid;
14133 }
14134
14135
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetl(&(tempguy.misc10),f,keepdata))
14136 {
14137 return qe_invalid;
14138 }
14139 31744 }
14140 else
14141 {
14142 int16_t tempMisc;
14143
14144 if(!p_igetw(&tempMisc,f,keepdata))
14145 {
14146 return qe_invalid;
14147 }
14148
14149 tempguy.misc1=tempMisc;
14150
14151 if(!p_igetw(&tempMisc,f,keepdata))
14152 {
14153 return qe_invalid;
14154 }
14155
14156 tempguy.misc2=tempMisc;
14157
14158 if(!p_igetw(&tempMisc,f,keepdata))
14159 {
14160 return qe_invalid;
14161 }
14162
14163 tempguy.misc3=tempMisc;
14164
14165 if(!p_igetw(&tempMisc,f,keepdata))
14166 {
14167 return qe_invalid;
14168 }
14169
14170 tempguy.misc4=tempMisc;
14171
14172 if(!p_igetw(&tempMisc,f,keepdata))
14173 {
14174 return qe_invalid;
14175 }
14176
14177 tempguy.misc5=tempMisc;
14178
14179 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14180 {
14181 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14182 tempguy.misc5 = 74;
14183 }
14184
14185 if(!p_igetw(&tempMisc,f,keepdata))
14186 {
14187 return qe_invalid;
14188 }
14189
14190 tempguy.misc6=tempMisc;
14191
14192 if(!p_igetw(&tempMisc,f,keepdata))
14193 {
14194 return qe_invalid;
14195 }
14196
14197 tempguy.misc7=tempMisc;
14198
14199 if(!p_igetw(&tempMisc,f,keepdata))
14200 {
14201 return qe_invalid;
14202 }
14203
14204 tempguy.misc8=tempMisc;
14205
14206 if(!p_igetw(&tempMisc,f,keepdata))
14207 {
14208 return qe_invalid;
14209 }
14210
14211 tempguy.misc9=tempMisc;
14212
14213 if(!p_igetw(&tempMisc,f,keepdata))
14214 {
14215 return qe_invalid;
14216 }
14217
14218 tempguy.misc10=tempMisc;
14219 }
14220
14221
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.bgsfx),f,keepdata))
14222 {
14223 return qe_invalid;
14224 }
14225
14226
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.bosspal),f,keepdata))
14227 {
14228 return qe_invalid;
14229 }
14230
14231
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetw(&(tempguy.extend),f,keepdata))
14232 {
14233 return qe_invalid;
14234 }
14235
14236 //! Enemy Defences
14237
14238 //If a 2.50 quest, use only the 2.5 defences.
14239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31744 times.
31744 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14240 {
14241
2/2
✓ Branch 0 taken 603136 times.
✓ Branch 1 taken 31744 times.
634880 for(int32_t j=0; j<edefLAST; j++)
14242 {
14243
1/2
✓ Branch 0 taken 603136 times.
✗ Branch 1 not taken.
603136 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14244 {
14245 return qe_invalid;
14246 }
14247 603136 }
14248 //then copy the generic script defence to all the new script defences
14249
14250 31744 }
14251
14252
14253
14254
14255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31744 times.
31744 if(guyversion >= 18)
14256 {
14257
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&(tempguy.hitsfx),f,keepdata))
14258 {
14259 return qe_invalid;
14260 }
14261
14262
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_getc(&(tempguy.deadsfx),f,keepdata))
14263 {
14264 return qe_invalid;
14265 }
14266 31744 }
14267
14268
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion >= 22)
14269 {
14270
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetl(&(tempguy.misc11),f,keepdata))
14271 {
14272 return qe_invalid;
14273 }
14274
14275
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!p_igetl(&(tempguy.misc12),f,keepdata))
14276 {
14277 return qe_invalid;
14278 }
14279 31744 }
14280 else if(guyversion >= 19)
14281 {
14282 int16_t tempMisc;
14283
14284 if(!p_igetw(&tempMisc,f,keepdata))
14285 {
14286 return qe_invalid;
14287 }
14288
14289 tempguy.misc11=tempMisc;
14290
14291 if(!p_igetw(&tempMisc,f,keepdata))
14292 {
14293 return qe_invalid;
14294 }
14295
14296 tempguy.misc12=tempMisc;
14297 }
14298
14299 //If a 2.54 or later quest, use all of the defences.
14300
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 1536 times.
31744 if(guyversion > 24) // Add new guyversion conditional statement
14301 {
14302
2/2
✓ Branch 0 taken 33792 times.
✓ Branch 1 taken 1536 times.
35328 for(int32_t j=edefLAST; j<edefLAST255; j++)
14303 {
14304
1/2
✓ Branch 0 taken 33792 times.
✗ Branch 1 not taken.
33792 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14305 {
14306 return qe_invalid;
14307 }
14308 33792 }
14309 1536 }
14310
14311
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14312 {
14313
2/2
✓ Branch 0 taken 302080 times.
✓ Branch 1 taken 30208 times.
332288 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14314 {
14315 302080 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14316 302080 }
14317 30208 }
14318
14319 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14320
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 1536 times.
31744 if(guyversion > 25)
14321 {
14322
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.txsz),f,keepdata))
14323 {
14324 return qe_invalid;
14325 }
14326
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.tysz),f,keepdata))
14327 {
14328 return qe_invalid;
14329 }
14330
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.hxsz),f,keepdata))
14331 {
14332 return qe_invalid;
14333 }
14334
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.hysz),f,keepdata))
14335 {
14336 return qe_invalid;
14337 }
14338
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.hzsz),f,keepdata))
14339 {
14340 return qe_invalid;
14341 }
14342 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14343
14344 */
14345 1536 }
14346 //More Enemy Editor vars for 2.60
14347
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 1536 times.
31744 if(guyversion > 26)
14348 {
14349
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.hxofs),f,keepdata))
14350 {
14351 return qe_invalid;
14352 }
14353
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.hyofs),f,keepdata))
14354 {
14355 return qe_invalid;
14356 }
14357
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.xofs),f,keepdata))
14358 {
14359 return qe_invalid;
14360 }
14361
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.yofs),f,keepdata))
14362 {
14363 return qe_invalid;
14364 }
14365
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.zofs),f,keepdata))
14366 {
14367 return qe_invalid;
14368 }
14369 1536 }
14370
14371
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14372 {
14373 30208 tempguy.wpnsprite = 0;
14374 30208 }
14375
14376
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 1536 times.
31744 if(guyversion > 27)
14377 {
14378
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.wpnsprite),f,keepdata))
14379 {
14380 return qe_invalid;
14381 }
14382 1536 }
14383
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14384 {
14385 30208 tempguy.SIZEflags = 0;
14386 30208 }
14387
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 1536 times.
31744 if(guyversion > 28)
14388 {
14389
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.SIZEflags),f,keepdata))
14390 {
14391 return qe_invalid;
14392 }
14393
14394 1536 }
14395
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14396 {
14397 30208 tempguy.frozentile = 0;
14398 30208 tempguy.frozencset = 0;
14399 30208 tempguy.frozenclock = 0;
14400
2/2
✓ Branch 0 taken 302080 times.
✓ Branch 1 taken 30208 times.
332288 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14401 30208 }
14402
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 1536 times.
31744 if(guyversion >= 30)
14403 {
14404
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.frozentile),f,keepdata))
14405 {
14406 return qe_invalid;
14407 }
14408
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.frozencset),f,keepdata))
14409 {
14410 return qe_invalid;
14411 }
14412
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.frozenclock),f,keepdata))
14413 {
14414 return qe_invalid;
14415 }
14416
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 1536 times.
16896 for ( int32_t q = 0; q < 10; q++ ) {
14417
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetw(&(tempguy.frozenmisc[q]),f,keepdata))
14418 {
14419 return qe_invalid;
14420 }
14421 15360 }
14422
14423 1536 }
14424
14425
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 1536 times.
31744 if(guyversion >= 34)
14426 {
14427
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&(tempguy.firesfx),f,keepdata))
14428 {
14429 return qe_invalid;
14430 }
14431
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc16),f,keepdata))
14432 {
14433 return qe_invalid;
14434 }
14435
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc17),f,keepdata))
14436 {
14437 return qe_invalid;
14438 }
14439
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc18),f,keepdata))
14440 {
14441 return qe_invalid;
14442 }
14443
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc19),f,keepdata))
14444 {
14445 return qe_invalid;
14446 }
14447
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc20),f,keepdata))
14448 {
14449 return qe_invalid;
14450 }
14451
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc21),f,keepdata))
14452 {
14453 return qe_invalid;
14454 }
14455
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc22),f,keepdata))
14456 {
14457 return qe_invalid;
14458 }
14459
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc23),f,keepdata))
14460 {
14461 return qe_invalid;
14462 }
14463
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc24),f,keepdata))
14464 {
14465 return qe_invalid;
14466 }
14467
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc25),f,keepdata))
14468 {
14469 return qe_invalid;
14470 }
14471
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc26),f,keepdata))
14472 {
14473 return qe_invalid;
14474 }
14475
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc27),f,keepdata))
14476 {
14477 return qe_invalid;
14478 }
14479
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc28),f,keepdata))
14480 {
14481 return qe_invalid;
14482 }
14483
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc29),f,keepdata))
14484 {
14485 return qe_invalid;
14486 }
14487
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc30),f,keepdata))
14488 {
14489 return qe_invalid;
14490 }
14491
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc31),f,keepdata))
14492 {
14493 return qe_invalid;
14494 }
14495
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc32),f,keepdata))
14496 {
14497 return qe_invalid;
14498 }
14499
14500
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 1536 times.
50688 for ( int32_t q = 0; q < 32; q++ ) {
14501
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.movement[q]),f,keepdata))
14502 {
14503 return qe_invalid;
14504 }
14505 49152 }
14506
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 1536 times.
50688 for ( int32_t q = 0; q < 32; q++ ) {
14507
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.new_weapon[q]),f,keepdata))
14508 {
14509 return qe_invalid;
14510 }
14511 49152 }
14512
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&(tempguy.script),f,keepdata))
14513 {
14514 return qe_invalid;
14515 }
14516 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14517
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for ( int32_t q = 0; q < 8; q++ )
14518 {
14519
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.initD[q]),f,keepdata))
14520 {
14521 return qe_invalid;
14522 }
14523 12288 }
14524
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1536 times.
4608 for ( int32_t q = 0; q < 2; q++ )
14525 {
14526
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&(tempguy.initA[q]),f,keepdata))
14527 {
14528 return qe_invalid;
14529 }
14530 3072 }
14531
14532 1536 }
14533
14534
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 1536 times.
31744 if(guyversion >= 37)
14535 {
14536
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.editorflags),f,keepdata))
14537 {
14538 return qe_invalid;
14539 }
14540 1536 }
14541
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14542
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 1536 times.
31744 if(guyversion >= 38)
14543 {
14544
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc13),f,keepdata))
14545 {
14546 return qe_invalid;
14547 }
14548
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc14),f,keepdata))
14549 {
14550 return qe_invalid;
14551 }
14552
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.misc15),f,keepdata))
14553 {
14554 return qe_invalid;
14555 }
14556
14557 1536 }
14558
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if ( guyversion < 38 )
14559 {
14560 30208 tempguy.misc13 = 0;
14561 30208 tempguy.misc14 = 0;
14562 30208 tempguy.misc15 = 0;
14563 30208 }
14564
14565
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 1536 times.
31744 if ( guyversion >= 39 )
14566 {
14567
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for ( int32_t q = 0; q < 8; q++ )
14568 {
14569
2/2
✓ Branch 0 taken 798720 times.
✓ Branch 1 taken 12288 times.
811008 for ( int32_t w = 0; w < 65; w++ )
14570 {
14571
1/2
✓ Branch 0 taken 798720 times.
✗ Branch 1 not taken.
798720 if(!p_getc(&(tempguy.initD_label[q][w]),f,keepdata))
14572 {
14573 return qe_invalid;
14574 }
14575 798720 }
14576
2/2
✓ Branch 0 taken 798720 times.
✓ Branch 1 taken 12288 times.
811008 for ( int32_t w = 0; w < 65; w++ )
14577 {
14578
1/2
✓ Branch 0 taken 798720 times.
✗ Branch 1 not taken.
798720 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f,keepdata))
14579 {
14580 return qe_invalid;
14581 }
14582 798720 }
14583 12288 }
14584
14585
14586 1536 }
14587
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if ( guyversion < 39 ) //apply old InitD strings to both
14588 {
14589 30208 al_trace("Populating InitD Label Fields for NPCS\n");
14590
2/2
✓ Branch 0 taken 241664 times.
✓ Branch 1 taken 30208 times.
271872 for ( int32_t q = 0; q < 8; q++ )
14591 {
14592 241664 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14593 241664 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14594 241664 }
14595 30208 }
14596
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 1536 times.
31744 if ( guyversion >= 40 )
14597 {
14598
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&(tempguy.weaponscript),f,keepdata))
14599 {
14600 return qe_invalid;
14601 }
14602 1536 }
14603
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if ( guyversion < 40 )
14604 {
14605 30208 tempguy.weaponscript = 0;
14606 30208 }
14607 //eweapon script InitD
14608
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 1536 times.
31744 if ( guyversion >= 41 )
14609 {
14610
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 1536 times.
13824 for ( int32_t q = 0; q < 8; q++ )
14611 {
14612
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.weap_initiald[q]),f,keepdata))
14613 {
14614 return qe_invalid;
14615 }
14616 12288 }
14617
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if ( guy_cversion < 4 )
14618 {
14619 if ( tempguy.family == eeKEESE )
14620 {
14621
14622 if ( !tempguy.misc1 )
14623 {
14624 tempguy.misc16 = 120;
14625 tempguy.misc17 = 16;
14626
14627 }
14628 }
14629 if ( tempguy.family == eePEAHAT )
14630 {
14631 tempguy.misc16 = 80;
14632 tempguy.misc17 = 16;
14633 }
14634
14635 if ( tempguy.family == eeGHINI )
14636 {
14637 tempguy.misc16 = 120;
14638 tempguy.misc17 = 10;
14639 }
14640
14641 }
14642 1536 }
14643
14644
14645
14646 //default weapon sprites (quest version < 2.54)
14647 //port over old defaults -Z
14648
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if(guyversion < 32)
14649 {
14650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30208 times.
30208 if ( tempguy.wpnsprite <= 0 )
14651 {
14652
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1004 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25109 times.
✓ Branch 4 taken 223 times.
✓ Branch 5 taken 249 times.
✓ Branch 6 taken 739 times.
✓ Branch 7 taken 367 times.
✓ Branch 8 taken 699 times.
✓ Branch 9 taken 59 times.
✓ Branch 10 taken 13 times.
✓ Branch 11 taken 105 times.
✓ Branch 12 taken 13 times.
✓ Branch 13 taken 272 times.
✓ Branch 14 taken 584 times.
✓ Branch 15 taken 79 times.
✓ Branch 16 taken 59 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 634 times.
30208 switch(tempguy.weapon)
14653 {
14654 case wNone:
14655 25109 tempguy.wpnsprite = 0; break;
14656
14657 case wSword:
14658 case wBeam:
14659 case wBrang:
14660 case wBomb:
14661 case wSBomb:
14662 case wLitBomb:
14663 case wLitSBomb:
14664 case wArrow:
14665 case wFire:
14666 case wWhistle:
14667 case wBait:
14668 case wWand:
14669 case wMagic:
14670 case wCatching:
14671 case wWind:
14672 case wRefMagic:
14673 case wRefFireball:
14674 case wRefRock:
14675 case wHammer:
14676 case wHookshot:
14677 case wHSHandle:
14678 case wHSChain:
14679 case wSSparkle:
14680 case wFSparkle:
14681 case wSmack:
14682 case wPhantom:
14683 case wCByrna:
14684 case wRefBeam:
14685 case wStomp:
14686 case lwMax:
14687 case wScript1:
14688 case wScript2:
14689 case wScript3:
14690 case wScript4:
14691 case wScript5:
14692 case wScript6:
14693 case wScript7:
14694 case wScript8:
14695 case wScript9:
14696 case wScript10:
14697 case wIce:
14698 //Cannot use any of these weapons yet.
14699 tempguy.wpnsprite = -1;
14700 break;
14701
14702 case wEnemyWeapons:
14703 1004 case ewFireball: tempguy.wpnsprite = 17; break;
14704
14705 223 case ewArrow: tempguy.wpnsprite = 19; break;
14706 249 case ewBrang: tempguy.wpnsprite = 4; break;
14707 739 case ewSword: tempguy.wpnsprite = 20; break;
14708 367 case ewRock: tempguy.wpnsprite = 18; break;
14709 699 case ewMagic: tempguy.wpnsprite = 21; break;
14710 59 case ewBomb: tempguy.wpnsprite = 78; break;
14711 13 case ewSBomb: tempguy.wpnsprite = 79; break;
14712 105 case ewLitBomb: tempguy.wpnsprite = 76; break;
14713 13 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14714 272 case ewFireTrail: tempguy.wpnsprite = 80; break;
14715 584 case ewFlame: tempguy.wpnsprite = 35; break;
14716 79 case ewWind: tempguy.wpnsprite = 36; break;
14717 59 case ewFlame2: tempguy.wpnsprite = 81; break;
14718 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14719 case ewIce: tempguy.wpnsprite = 83; break;
14720 634 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14721
14722
14723 default: break; //No assign.
14724 }
14725 30208 }
14726 30208 }
14727
14728 //default weapon fire sound (quest version < 2.54)
14729 //port over old defaults and zero new data. -Z
14730
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if(guyversion < 34)
14731 {
14732
2/2
✓ Branch 0 taken 966656 times.
✓ Branch 1 taken 30208 times.
996864 for ( int32_t q = 0; q < 32; q++ )
14733 {
14734 966656 tempguy.movement[q] = 0;
14735 966656 tempguy.new_weapon[q] = 0;
14736
14737 966656 }
14738
14739 //NPC Script attributes.
14740 30208 tempguy.script = 0; //No scripted enemies existed. -Z
14741
2/2
✓ Branch 0 taken 241664 times.
✓ Branch 1 taken 30208 times.
271872 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14742
2/2
✓ Branch 0 taken 60416 times.
✓ Branch 1 taken 30208 times.
90624 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14743
14744 30208 tempguy.misc16 = 0;
14745 30208 tempguy.misc17 = 0;
14746 30208 tempguy.misc18 = 0;
14747 30208 tempguy.misc19 = 0;
14748 30208 tempguy.misc20 = 0;
14749 30208 tempguy.misc21 = 0;
14750 30208 tempguy.misc22 = 0;
14751 30208 tempguy.misc23 = 0;
14752 30208 tempguy.misc24 = 0;
14753 30208 tempguy.misc25 = 0;
14754 30208 tempguy.misc26 = 0;
14755 30208 tempguy.misc27 = 0;
14756 30208 tempguy.misc28 = 0;
14757 30208 tempguy.misc29 = 0;
14758 30208 tempguy.misc30 = 0;
14759 30208 tempguy.misc31 = 0;
14760 30208 tempguy.misc32 = 0;
14761
14762 //old default sounds
14763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30208 times.
30208 if ( tempguy.firesfx <= 0 )
14764 {
14765
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1004 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25109 times.
✓ Branch 4 taken 223 times.
✓ Branch 5 taken 249 times.
✓ Branch 6 taken 739 times.
✓ Branch 7 taken 367 times.
✓ Branch 8 taken 699 times.
✓ Branch 9 taken 59 times.
✓ Branch 10 taken 13 times.
✓ Branch 11 taken 105 times.
✓ Branch 12 taken 13 times.
✓ Branch 13 taken 272 times.
✓ Branch 14 taken 584 times.
✓ Branch 15 taken 79 times.
✓ Branch 16 taken 59 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 634 times.
30208 switch(tempguy.weapon)
14766 {
14767 case wNone:
14768 25109 tempguy.firesfx = 0; break;
14769
14770 case wSword:
14771 case wBeam:
14772 case wBrang:
14773 case wBomb:
14774 case wSBomb:
14775 case wLitBomb:
14776 case wLitSBomb:
14777 case wArrow:
14778 case wFire:
14779 case wWhistle:
14780 case wBait:
14781 case wWand:
14782 case wMagic:
14783 case wCatching:
14784 case wWind:
14785 case wRefMagic:
14786 case wRefFireball:
14787 case wRefRock:
14788 case wHammer:
14789 case wHookshot:
14790 case wHSHandle:
14791 case wHSChain:
14792 case wSSparkle:
14793 case wFSparkle:
14794 case wSmack:
14795 case wPhantom:
14796 case wCByrna:
14797 case wRefBeam:
14798 case wStomp:
14799 case lwMax:
14800 case wScript1:
14801 case wScript2:
14802 case wScript3:
14803 case wScript4:
14804 case wScript5:
14805 case wScript6:
14806 case wScript7:
14807 case wScript8:
14808 case wScript9:
14809 case wScript10:
14810 case wIce:
14811 //Cannot use any of these weapons yet.
14812 tempguy.firesfx = -1;
14813 break;
14814
14815 case wEnemyWeapons:
14816 1004 case ewFireball: tempguy.firesfx = 40; break;
14817
14818 223 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14819 249 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14820 739 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14821 367 case ewRock: tempguy.firesfx = 51; break;
14822 699 case ewMagic: tempguy.firesfx = 32; break;
14823 59 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14824 13 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14825 105 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14826 13 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14827 272 case ewFireTrail: tempguy.firesfx = 13; break;
14828 584 case ewFlame: tempguy.firesfx = 13; break;
14829 79 case ewWind: tempguy.firesfx = 32; break;
14830 59 case ewFlame2: tempguy.firesfx = 13; break;
14831 case ewFlame2Trail: tempguy.firesfx = 13; break;
14832 case ewIce: tempguy.firesfx = 44; break;
14833 634 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14834
14835 //what about special attacks (e.g. summoning == 56)
14836 default: break; //No assign.
14837 }
14838 30208 }
14839 30208 }
14840
14841 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14842
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1536 times.
31744 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14843 {
14844
2/2
✓ Branch 0 taken 2433 times.
✓ Branch 1 taken 27775 times.
30208 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14845 30208 }
14846 //Keese and bat halt rates.
14847
3/4
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 1536 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30208 times.
31744 if ( guyversion < 42 && guy_cversion < 4 )
14848 {
14849
14850
2/2
✓ Branch 0 taken 29788 times.
✓ Branch 1 taken 420 times.
30208 if ( tempguy.family == eeKEESE )
14851 {
14852
14853
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 249 times.
420 if ( !tempguy.misc1 )
14854 {
14855 249 tempguy.misc16 = 120;
14856 249 tempguy.misc17 = 16;
14857
14858 249 }
14859 420 }
14860
2/2
✓ Branch 0 taken 30080 times.
✓ Branch 1 taken 128 times.
30208 if ( tempguy.family == eePEAHAT )
14861 {
14862 128 tempguy.misc16 = 80;
14863 128 tempguy.misc17 = 16;
14864 128 }
14865
2/2
✓ Branch 0 taken 30149 times.
✓ Branch 1 taken 59 times.
30208 if ( tempguy.family == eeGHINI )
14866 {
14867 59 tempguy.misc16 = 120;
14868 59 tempguy.misc17 = 10;
14869 59 }
14870
14871
14872 30208 }
14873
14874
14875 //miscellaneous other corrections
14876 //fix the mirror wizzrobe -DD
14877
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion < 7)
14878 {
14879 if(i == eMWIZ)
14880 {
14881 tempguy.misc2 = 0;
14882 tempguy.misc4 = 1;
14883 }
14884 }
14885
14886
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion < 8)
14887 {
14888 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14889 {
14890 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14891 tempguy.misc5 = 4; //neck length in segments
14892 tempguy.misc6 = 8; //neck offset from first body tile
14893 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14894 tempguy.misc8 = 168; //head offset from first body tile
14895 tempguy.misc9 = 228; //flying head offset from first body tile
14896
14897 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14898 {
14899 tempguy.misc6 += 10; //neck offset from first body tile
14900 tempguy.misc8 -= 12; //head offset from first body tile
14901 }
14902 }
14903 }
14904
14905
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14906 {
14907 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14908 tempguy.bosspal = spDIG;
14909 }
14910
14911
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion < 11) // December 2007 - Spinning Tile fix
14912 {
14913 if(tempguy.family==eeSPINTILE)
14914 {
14915 tempguy.flags |= guy_superman;
14916 tempguy.item_set = 0; // Don't drop items
14917 tempguy.step = 300;
14918 }
14919 }
14920
14921
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14922 {
14923 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14924 {
14925 if(tempguy.family==eeROPE)
14926 {
14927 tempguy.flags2 &= ~guy_flashing;
14928 }
14929 }
14930
14931 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14932 {
14933 if(tempguy.family==eeBUBBLE)
14934 {
14935 tempguy.flags2 &= ~guy_flashing;
14936 }
14937 }
14938
14939 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14940 {
14941 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14942 {
14943 tempguy.flags2 |= guy_blinking;
14944 }
14945
14946 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14947 {
14948 tempguy.flags2 |= guy_transparent;
14949 }
14950 }
14951 }
14952
14953
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14954 {
14955 if(i==gFIRE)
14956 {
14957 tempguy.e_anim = aFLIP;
14958 tempguy.e_frate = 24;
14959 }
14960
14961 if(i==gFAIRY)
14962 {
14963 tempguy.e_anim = a2FRM;
14964 tempguy.e_frate = 16;
14965 }
14966 }
14967
14968
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14969 {
14970 if(i==0) Z_message("Updating guys to version 16...\n");
14971
14972 update_guy_1(&tempguy);
14973
14974 if(i==eMPOLSV)
14975 {
14976 tempguy.defense[edefARROW] = edCHINK;
14977 tempguy.defense[edefMAGIC] = ed1HKO;
14978 tempguy.defense[edefREFMAGIC] = ed1HKO;
14979 }
14980 }
14981
14982
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion < 17) // December 2009
14983 {
14984 if(tempguy.family==eePROJECTILE)
14985 {
14986 tempguy.misc1 = 0;
14987 }
14988 }
14989
14990
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion < 18) // January 2010
14991 {
14992 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14993 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14994
14995 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14996 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
14997
14998 if(tempguy.family == eeAQUA)
14999 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15000 else if(tempguy.family == eeMANHAN)
15001 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15002 else if(tempguy.family==eePATRA)
15003 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15004 else if(tempguy.family==eeGHOMA)
15005 {
15006 for(int32_t j=0; j<edefLAST; j++)
15007 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15008
15009 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15010
15011 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15012
15013 tempguy.misc1--;
15014 }
15015 else if(tempguy.family == eeGLEEOK)
15016 {
15017 for(int32_t j=0; j<edefLAST; j++)
15018 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15019
15020 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15021 }
15022 else if(tempguy.family == eeARMOS)
15023 {
15024 tempguy.family=eeWALK;
15025 tempguy.hrate = 0;
15026 tempguy.misc10 = tempguy.misc1;
15027 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15028 tempguy.misc9 = e9tARMOS;
15029 }
15030 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15031 {
15032 tempguy.family=eeWALK;
15033 tempguy.hrate = 0;
15034 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15035 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15036 }
15037
15038 // Spawn animation flags
15039 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15040 tempguy.flags |= guy_fadeflicker;
15041 else
15042 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15043 }
15044
15045
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion < 20) // April 2010
15046 {
15047 if(tempguy.family == eeTRAP)
15048 {
15049 tempguy.misc2 = tempguy.misc10;
15050
15051 if(tempguy.misc10>=1)
15052 {
15053 tempguy.misc1++;
15054 }
15055
15056 tempguy.misc10 = 0;
15057 }
15058
15059 // Bomb Blast fix
15060 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15061 tempguy.weapon = ewLitBomb;
15062 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15063 tempguy.weapon = ewLitSBomb;
15064 }
15065
15066
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion < 21) // September 2011
15067 {
15068 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15069 {
15070 if(tempguy.family == eeKEESETRIB)
15071 {
15072 tempguy.family = eeKEESE;
15073 tempguy.misc2 = e2tKEESETRIB;
15074 tempguy.misc1 = 0;
15075 }
15076
15077 tempguy.rate = 2;
15078 tempguy.hrate = 8;
15079 tempguy.homing = 0;
15080 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15081 }
15082 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15083 {
15084 if(tempguy.family == eePEAHAT)
15085 {
15086 tempguy.rate = 4;
15087 tempguy.step = 62;
15088 }
15089 else
15090 tempguy.step = 25;
15091
15092 tempguy.hrate = 8;
15093 tempguy.homing = 0;
15094 }
15095 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15096 {
15097 if(tempguy.family == eeMANHAN)
15098 tempguy.step=50;
15099
15100 tempguy.hrate = 16;
15101 tempguy.homing = 0;
15102 }
15103 else if(tempguy.family == eeGLEEOK)
15104 {
15105 tempguy.rate = 2;
15106 tempguy.homing = 0;
15107 tempguy.hrate = 9;
15108 tempguy.step=89;
15109 }
15110 else if(tempguy.family == eeGHINI)
15111 {
15112 tempguy.rate = 4;
15113 tempguy.hrate = 12;
15114 tempguy.step=62;
15115 tempguy.homing = 0;
15116 }
15117
15118 // Bigdig random rate fix
15119 if(tempguy.family==eeDIG && tempguy.misc10==1)
15120 {
15121 tempguy.rate = 2;
15122 }
15123 }
15124
15125
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(guyversion < 24) // November 2012
15126 {
15127 if(tempguy.family==eeLANM)
15128 tempguy.misc3 = 1;
15129 else if(tempguy.family==eeMOLD)
15130 tempguy.misc2 = 0;
15131 }
15132
15133
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15134 {
15135
2/2
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 29676 times.
30208 if(tempguy.family!=eeDIG)
15136 {
15137 29676 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15138 29676 }
15139
15140 30208 }
15141 // does not seem to solve the issue!
15142
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if ( Header->zelda_version <= 0x210 )
15143 {
15144 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15145 if ( tempguy.family == eeDONGO )
15146 {
15147 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15148 }
15149 }
15150
15151
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if(guyversion >= 42)
15152 {
15153
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(guyversion >= 47)
15154 {
15155
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetl(&(tempguy.moveflags),f,keepdata))
15156 {
15157 return qe_invalid;
15158 }
15159 1536 }
15160 else
15161 {
15162 byte fl;
15163 if(!p_getc(&fl,f,keepdata))
15164 {
15165 return qe_invalid;
15166 }
15167 tempguy.moveflags = fl;
15168 }
15169 1536 }
15170 else
15171 {
15172
7/8
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 23890 times.
✓ Branch 2 taken 942 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 385 times.
✓ Branch 5 taken 213 times.
✓ Branch 6 taken 184 times.
✓ Branch 7 taken 4544 times.
30208 switch(tempguy.family)
15173 {
15174 //No gravity; floats over pits
15175 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15176 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15177 //Special (bosses, etc)
15178 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15179 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15180 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15181 23890 tempguy.moveflags = FLAG_CAN_PITWALK;
15182 23890 break;
15183 //No gravity, but falls in pits
15184 case eeLEV:
15185 385 tempguy.moveflags = FLAG_CAN_PITFALL;
15186 385 break;
15187 //Bosses that respect pits
15188 case eeDONGO:
15189 213 tempguy.moveflags = FLAG_OBEYS_GRAV;
15190 213 break;
15191 case eeLANM:
15192 184 tempguy.moveflags = 0;
15193 184 break;
15194 //Gravity, floats over pits
15195 case eeWIZZ: case eeWALLM: case eeGHINI:
15196 942 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15197 942 break;
15198 //Gravity and falls in pits
15199 case eeWALK:
15200
4/4
✓ Branch 0 taken 4291 times.
✓ Branch 1 taken 253 times.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 4075 times.
4544 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15201 469 break;
15202 [[fallthrough]];
15203 case eeOTHER:
15204 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15205 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15206 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15207 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15208 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15209 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15210 4125 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15211 4125 }
15212 }
15213
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if(guyversion < 43)
15214 {
15215
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 5376 times.
30208 switch(tempguy.family)
15216 {
15217 //No gravity; floats over pits
15218 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15219 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15220 //Special (bosses, etc)
15221 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15222 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15223 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15224 case eeWIZZ: case eeWALLM: case eeGHINI:
15225 //Gravity, floats over pits
15226 24832 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15227 24832 break;
15228 }
15229 30208 }
15230
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if (guyversion < 44)
15231 {
15232
2/2
✓ Branch 0 taken 29911 times.
✓ Branch 1 taken 297 times.
30208 if ( tempguy.family == eeGHOMA )
15233 {
15234 297 tempguy.flags |= guy_fadeinstant;
15235 297 }
15236 30208 }
15237
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if (guyversion > 44)
15238 {
15239
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_getc(&(tempguy.spr_shadow),f,keepdata))
15240 {
15241 return qe_invalid;
15242 }
15243
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_getc(&(tempguy.spr_death),f,keepdata))
15244 {
15245 return qe_invalid;
15246 }
15247
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_getc(&(tempguy.spr_spawn),f,keepdata))
15248 {
15249 return qe_invalid;
15250 }
15251 1536 }
15252 else
15253 {
15254
2/2
✓ Branch 0 taken 30090 times.
✓ Branch 1 taken 118 times.
30208 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15255 30208 tempguy.spr_death = iwDeath;
15256 30208 tempguy.spr_spawn = iwSpawn;
15257 }
15258
15259
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 30208 times.
31744 if(guyversion < 46)
15260 {
15261
4/4
✓ Branch 0 taken 4544 times.
✓ Branch 1 taken 25664 times.
✓ Branch 2 taken 4291 times.
✓ Branch 3 taken 253 times.
30208 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15262 {
15263 253 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15264 253 }
15265 30208 }
15266
15267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31744 times.
31744 if(keepdata)
15268 {
15269 31744 guysbuf[i] = tempguy;
15270 31744 }
15271 31744 }
15272 62 }
15273
15274 62 return 0;
15275 62 }
15276
15277 void update_guy_1(guydata *tempguy) // November 2009
15278 {
15279 bool doesntcount = false;
15280 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15281
15282 switch(tempguy->family)
15283 {
15284 case 1: //eeWALK
15285 switch(tempguy->misc10)
15286 {
15287 case 0: //Stalfos
15288 if(tempguy->misc1==1) // Fires four projectiles at once
15289 tempguy->misc1=4;
15290
15291 break;
15292
15293 case 1: //Darknut
15294 goto darknuts;
15295 break;
15296 }
15297
15298 tempguy->misc10 = 0;
15299 break;
15300
15301 case 2: //eeSHOOT
15302 tempguy->family = eeWALK;
15303
15304 switch(tempguy->misc10)
15305 {
15306 case 0: //Octorok
15307 if(tempguy->misc1==1||tempguy->misc1==2)
15308 {
15309 tempguy->misc1=e1tFIREOCTO;
15310 tempguy->misc2=e2tFIREOCTO;
15311 }
15312 else tempguy->misc1 = 0;
15313
15314 tempguy->misc6=tempguy->misc4;
15315 tempguy->misc4=tempguy->misc3;
15316 tempguy->misc3=0;
15317 break;
15318
15319 case 1: // Moblin
15320 tempguy->misc1 = 0;
15321 break;
15322
15323 case 2: //Lynel
15324 tempguy->misc6=tempguy->misc1+1;
15325 tempguy->misc1=0;
15326 break;
15327
15328 case 3: //Stalfos 2
15329 if(tempguy->misc1==1) // Fires four projectiles at once
15330 tempguy->misc1=e1t4SHOTS;
15331 else tempguy->misc1 = 0;
15332
15333 break;
15334
15335 case 4: //Darknut 5
15336 darknuts:
15337 tempguy->defense[edefFIRE] = edIGNORE;
15338 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15339 tempguy->defense[edefHOOKSHOT] = 0;
15340 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15341 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15342
15343 if(tempguy->misc1==1)
15344 tempguy->misc1=2;
15345 else if(tempguy->misc1==2)
15346 {
15347 tempguy->misc4=tempguy->misc3;
15348 tempguy->misc3=tempguy->misc2;
15349 tempguy->misc2=e2tSPLIT;
15350 tempguy->misc1 = 0;
15351 }
15352 else tempguy->misc1 = 0;
15353
15354 tempguy->flags |= inv_front;
15355
15356 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15357 tempguy->flags |= guy_bkshield;
15358
15359 break;
15360 }
15361
15362 tempguy->misc10 = 0;
15363 break;
15364
15365 /*
15366 case 9: //eeARMOS
15367 tempguy->family = eeWALK;
15368 break;
15369 */
15370 case 11: //eeGEL
15371 case 33: //eeGELTRIB
15372 if(tempguy->family==33)
15373 {
15374 tempguy->misc4 = 1;
15375
15376 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15377 tempguy->misc3 = tempguy->misc2;
15378
15379 tempguy->misc2 = e2tTRIBBLE;
15380 }
15381 else
15382 {
15383 tempguy->misc4 = 0;
15384 tempguy->misc3 = 0;
15385 tempguy->misc2 = 0;
15386 }
15387
15388 tempguy->family = eeWALK;
15389
15390 if(tempguy->misc1)
15391 {
15392 tempguy->misc1=1;
15393 tempguy->weapon = ewFireTrail;
15394 }
15395
15396 break;
15397
15398 case 34: //eeZOLTRIB
15399 case 12: //eeZOL
15400 tempguy->misc4=tempguy->misc3;
15401 tempguy->misc3=tempguy->misc2;
15402 tempguy->family = eeWALK;
15403 tempguy->misc2=e2tSPLITHIT;
15404
15405 if(tempguy->misc1)
15406 {
15407 tempguy->misc1=1;
15408 tempguy->weapon = ewFireTrail;
15409 }
15410
15411 break;
15412
15413 case 13: //eeROPE
15414 tempguy->family = eeWALK;
15415 tempguy->misc9 = e9tROPE;
15416
15417 if(tempguy->misc1)
15418 {
15419 tempguy->misc4 = tempguy->misc3;
15420 tempguy->misc3 = tempguy->misc2;
15421 tempguy->misc2 = e2tBOMBCHU;
15422 }
15423
15424 tempguy->misc1 = 0;
15425 break;
15426
15427 case 14: //eeGORIYA
15428 tempguy->family = eeWALK;
15429
15430 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15431
15432 break;
15433
15434 case 17: //eeBUBBLE
15435 tempguy->family = eeWALK;
15436 tempguy->misc8 = tempguy->misc2;
15437 tempguy->misc7 = tempguy->misc1 + 1;
15438 tempguy->misc1 = tempguy->misc2 = 0;
15439
15440 //fallthrogh
15441 case eeTRAP:
15442 case eeROCK:
15443 doesntcount = true;
15444 break;
15445
15446 case 35: //eeVIRETRIB
15447 case 18: //eeVIRE
15448 tempguy->family = eeWALK;
15449 tempguy->misc4=tempguy->misc3;
15450 tempguy->misc3=tempguy->misc2;
15451 tempguy->misc2=e2tSPLITHIT;
15452 tempguy->misc9=e9tVIRE;
15453 break;
15454
15455 case 19: //eeLIKE
15456 tempguy->family = eeWALK;
15457 tempguy->misc7 = e7tEATITEMS;
15458 tempguy->misc8=95;
15459 break;
15460
15461 case 20: //eePOLSV
15462 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15463 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15464 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15465 tempguy->defense[edefARROW] = ed1HKO;
15466 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15467 tempguy->family = eeWALK;
15468 tempguy->misc9 = e9tPOLSVOICE;
15469 tempguy->rate = 4;
15470 tempguy->homing = 32;
15471 tempguy->hrate = 10;
15472 tempguy->grumble = 0;
15473 break;
15474
15475 case eeWIZZ:
15476 if(tempguy->misc4)
15477 {
15478 for(int32_t i=0; i < edefLAST; i++)
15479 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15480 }
15481 else
15482 {
15483 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15484 tempguy->defense[edefMAGIC] = edCHINK;
15485 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15486 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15487 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15488 }
15489
15490 break;
15491
15492 case eePEAHAT:
15493 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15494
15495 if(!(tempguy->flags & guy_bhit))
15496 tempguy->defense[edefBRANG] = edSTUNONLY;
15497
15498 break;
15499
15500 case eeLEV:
15501 tempguy->defense[edefSTOMP] = edCHINK;
15502 break;
15503 }
15504
15505 // Old flags
15506 if(tempguy->flags & guy_superman)
15507 {
15508 for(int32_t i = 0; i < edefLAST; i++)
15509 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15510 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15511 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15512 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15513 }
15514
15515 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15516
15517 if(doesntcount)
15518 tempguy->flags |= (guy_doesntcount);
15519 }
15520
15521
15522 98872 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15523 {
15524 byte tempbyte, padding;
15525 int32_t extras, secretcombos;
15526 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->valid),f,true))
15528 {
15529 return qe_invalid;
15530 }
15531
15532
15533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->guy),f,true))
15534 {
15535 return qe_invalid;
15536 }
15537
15538
2/6
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98872 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15539 {
15540 if(!p_getc(&tempbyte,f,true))
15541 {
15542 return qe_invalid;
15543 }
15544
15545 temp_mapscr->str=tempbyte;
15546 }
15547 else
15548 {
15549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_igetw(&(temp_mapscr->str),f,true))
15550 {
15551 return qe_invalid;
15552 }
15553 }
15554
15555
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->room),f,true))
15556 {
15557 return qe_invalid;
15558 }
15559
15560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->item),f,true))
15561 {
15562 return qe_invalid;
15563 }
15564
15565
2/6
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98872 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15566 {
15567 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15568 }
15569 else
15570 {
15571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->hasitem),f,true))
15572 return qe_invalid;
15573 }
15574
15575
1/4
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98872 if((Header->zelda_version < 0x192)||
15576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15577 {
15578 if(!p_getc(&tempbyte,f,true))
15579 {
15580 return qe_invalid;
15581 }
15582 }
15583
15584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f,true))
15585 {
15586 return qe_invalid;
15587 }
15588
15589
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(Header->zelda_version < 0x193)
15590 {
15591 if(!p_getc(&tempbyte,f,true))
15592 {
15593 return qe_invalid;
15594 }
15595 }
15596
15597
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15598 {
15599
2/2
✓ Branch 0 taken 296616 times.
✓ Branch 1 taken 98872 times.
395488 for(int32_t i=1; i<4; i++)
15600 {
15601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296616 times.
296616 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
15602 {
15603 return qe_invalid;
15604 }
15605 296616 }
15606 98872 }
15607 else
15608 {
15609 temp_mapscr->tilewarptype[1]=0;
15610 temp_mapscr->tilewarptype[2]=0;
15611 temp_mapscr->tilewarptype[3]=0;
15612 }
15613
15614
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15615 {
15616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
15617 {
15618 return qe_invalid;
15619 }
15620 98872 }
15621
15622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f,true))
15623 {
15624 return qe_invalid;
15625 }
15626
15627 98872 temp_mapscr->warpreturnx[1]=0;
15628 98872 temp_mapscr->warpreturnx[2]=0;
15629 98872 temp_mapscr->warpreturnx[3]=0;
15630
15631
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15632 {
15633
2/2
✓ Branch 0 taken 296616 times.
✓ Branch 1 taken 98872 times.
395488 for(int32_t i=1; i<4; i++)
15634 {
15635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296616 times.
296616 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
15636 {
15637 return qe_invalid;
15638 }
15639 296616 }
15640 98872 }
15641
15642
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->warpreturny[0]),f,true))
15643 {
15644 return qe_invalid;
15645 }
15646
15647 98872 temp_mapscr->warpreturny[1]=0;
15648 98872 temp_mapscr->warpreturny[2]=0;
15649 98872 temp_mapscr->warpreturny[3]=0;
15650
15651
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15652 {
15653
2/2
✓ Branch 0 taken 296616 times.
✓ Branch 1 taken 98872 times.
395488 for(int32_t i=1; i<4; i++)
15654 {
15655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296616 times.
296616 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
15656 {
15657 return qe_invalid;
15658 }
15659 296616 }
15660
15661
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(version>=18)
15662 {
15663
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
15664 {
15665 return qe_invalid;
15666 }
15667 98872 }
15668 else
15669 {
15670 byte temp;
15671
15672 if(!p_getc(&temp,f,true))
15673 {
15674 return qe_invalid;
15675 }
15676
15677 temp_mapscr->warpreturnc=temp<<8|temp;
15678 }
15679 98872 }
15680
15681
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->stairx),f,true))
15682
15683 {
15684 return qe_invalid;
15685 }
15686
15687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->stairy),f,true))
15688 {
15689 return qe_invalid;
15690 }
15691
15692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->itemx),f,true))
15693 {
15694 return qe_invalid;
15695 }
15696
15697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->itemy),f,true))
15698 {
15699 return qe_invalid;
15700 }
15701
15702
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(version > 15) // February 2009
15703 {
15704
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_igetw(&(temp_mapscr->color),f,true))
15705 {
15706 return qe_invalid;
15707 }
15708 98872 }
15709 else
15710 {
15711 if(!p_getc(& tempbyte,f,true))
15712 {
15713 return qe_invalid;
15714 }
15715
15716 temp_mapscr->color = (word) tempbyte;
15717 }
15718
15719
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
15720 {
15721 return qe_invalid;
15722 }
15723
15724
2/2
✓ Branch 0 taken 395488 times.
✓ Branch 1 taken 98872 times.
494360 for(int32_t k=0; k<4; k++)
15725 {
15726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395488 times.
395488 if(!p_getc(&(temp_mapscr->door[k]),f,true))
15727 {
15728 return qe_invalid;
15729
15730 }
15731 395488 }
15732
15733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(version <= 11)
15734 {
15735 if(!p_getc(&(tempbyte),f,true))
15736 {
15737 return qe_invalid;
15738 }
15739
15740 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15741
15742 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15743 {
15744 for(int32_t i=1; i<4; i++)
15745 {
15746 if(!p_getc(&(tempbyte),f,true))
15747 {
15748 return qe_invalid;
15749 }
15750
15751 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15752 }
15753 }
15754 else
15755 {
15756 temp_mapscr->tilewarpdmap[1]=0;
15757 temp_mapscr->tilewarpdmap[2]=0;
15758 temp_mapscr->tilewarpdmap[3]=0;
15759 }
15760 }
15761 else
15762 {
15763
2/2
✓ Branch 0 taken 395488 times.
✓ Branch 1 taken 98872 times.
494360 for(int32_t i=0; i<4; i++)
15764 {
15765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395488 times.
395488 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
15766 {
15767 return qe_invalid;
15768 }
15769 395488 }
15770 }
15771
15772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f,true))
15773 {
15774 return qe_invalid;
15775 }
15776
15777
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15778 {
15779
2/2
✓ Branch 0 taken 296616 times.
✓ Branch 1 taken 98872 times.
395488 for(int32_t i=1; i<4; i++)
15780 {
15781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296616 times.
296616 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
15782 {
15783 return qe_invalid;
15784 }
15785 296616 }
15786 98872 }
15787 else
15788 {
15789 temp_mapscr->tilewarpscr[1]=0;
15790 temp_mapscr->tilewarpscr[2]=0;
15791 temp_mapscr->tilewarpscr[3]=0;
15792 }
15793
15794
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(version >= 15)
15795 {
15796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
15797 {
15798 return qe_invalid;
15799 }
15800 98872 }
15801 else
15802 {
15803 temp_mapscr->tilewarpoverlayflags=0;
15804 }
15805
15806
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->exitdir),f,true))
15807 {
15808 return qe_invalid;
15809 }
15810
15811
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(Header->zelda_version < 0x193)
15812 {
15813 if(!p_getc(&tempbyte,f,true))
15814 {
15815 return qe_invalid;
15816 }
15817
15818 }
15819
15820
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15821 {
15822 if(!p_getc(&padding,f,true))
15823 {
15824 return qe_invalid;
15825 }
15826 }
15827
15828
2/2
✓ Branch 0 taken 988720 times.
✓ Branch 1 taken 98872 times.
1087592 for(int32_t k=0; k<10; k++)
15829 {
15830 /*
15831 if (!temp_mapscr->enemy[k])
15832 {
15833 continue;
15834 }
15835 */
15836
2/6
✓ Branch 0 taken 988720 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 988720 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
988720 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15837 {
15838 if(!p_getc(&tempbyte,f,true))
15839 {
15840 return qe_invalid;
15841 }
15842
15843 temp_mapscr->enemy[k]=tempbyte;
15844 }
15845 else
15846 {
15847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988720 times.
988720 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
15848 {
15849 return qe_invalid;
15850 }
15851 }
15852
15853
2/6
✓ Branch 0 taken 988720 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 988720 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
988720 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15854 {
15855 //using enumerations here is dangerous
15856 //very easy to break old quests -DD
15857 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15858 {
15859 temp_mapscr->enemy[k]+=5;
15860 }
15861 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15862 {
15863 temp_mapscr->enemy[k]+=1;
15864 }
15865 }
15866
15867
1/2
✓ Branch 0 taken 988720 times.
✗ Branch 1 not taken.
988720 if(version < 9)
15868 {
15869 if(temp_mapscr->enemy[k]>0)
15870 {
15871 temp_mapscr->enemy[k]+=10;
15872 }
15873 }
15874 //don't read in any invalid data
15875
1/2
✓ Branch 0 taken 988720 times.
✗ Branch 1 not taken.
988720 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15876 {
15877 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15878 temp_mapscr->enemy[k] = 0;
15879 }
15880 988720 }
15881
15882
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->pattern),f,true))
15883 {
15884 return qe_invalid;
15885 }
15886
15887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f,true))
15888 {
15889 return qe_invalid;
15890 }
15891
15892
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15893 {
15894
2/2
✓ Branch 0 taken 296616 times.
✓ Branch 1 taken 98872 times.
395488 for(int32_t i=1; i<4; i++)
15895 {
15896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296616 times.
296616 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
15897 {
15898 return qe_invalid;
15899 }
15900 296616 }
15901 98872 }
15902 else
15903 {
15904 temp_mapscr->sidewarptype[1]=0;
15905 temp_mapscr->sidewarptype[2]=0;
15906 temp_mapscr->sidewarptype[3]=0;
15907 }
15908
15909
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(version >= 15)
15910 {
15911
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
15912 {
15913 return qe_invalid;
15914 }
15915 98872 }
15916 else
15917 {
15918 temp_mapscr->sidewarpoverlayflags=0;
15919 }
15920
15921
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
15922 {
15923 return qe_invalid;
15924 }
15925
15926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
15927 {
15928 return qe_invalid;
15929 }
15930
15931
2/2
✓ Branch 0 taken 395488 times.
✓ Branch 1 taken 98872 times.
494360 for(int32_t k=0; k<4; k++)
15932 {
15933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395488 times.
395488 if(!p_getc(&(temp_mapscr->path[k]),f,true))
15934 {
15935 return qe_invalid;
15936 }
15937 395488 }
15938
15939
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f,true))
15940 {
15941 return qe_invalid;
15942 }
15943
15944
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15945 {
15946
2/2
✓ Branch 0 taken 98872 times.
✓ Branch 1 taken 296616 times.
395488 for(int32_t i=1; i<4; i++)
15947 {
15948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296616 times.
296616 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
15949 {
15950 return qe_invalid;
15951 }
15952 296616 }
15953 98872 }
15954 else
15955 {
15956 temp_mapscr->sidewarpscr[1]=0;
15957 temp_mapscr->sidewarpscr[2]=0;
15958 temp_mapscr->sidewarpscr[3]=0;
15959 }
15960
15961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(version <= 11)
15962 {
15963 if(!p_getc(&(tempbyte),f,true))
15964 {
15965 return qe_invalid;
15966 }
15967
15968 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15969
15970 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15971 {
15972 for(int32_t i=1; i<4; i++)
15973 {
15974 if(!p_getc(&(tempbyte),f,true))
15975 {
15976 return qe_invalid;
15977 }
15978
15979 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15980 }
15981 }
15982 else
15983 {
15984 temp_mapscr->sidewarpdmap[1]=0;
15985 temp_mapscr->sidewarpdmap[2]=0;
15986 temp_mapscr->sidewarpdmap[3]=0;
15987 }
15988 }
15989 else
15990 {
15991
2/2
✓ Branch 0 taken 395488 times.
✓ Branch 1 taken 98872 times.
494360 for(int32_t i=0; i<4; i++)
15992 {
15993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395488 times.
395488 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
15994 {
15995 return qe_invalid;
15996 }
15997 395488 }
15998 }
15999
16000
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16001 {
16002
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
16003 {
16004 return qe_invalid;
16005 }
16006 98872 }
16007 else temp_mapscr->sidewarpindex = 0;
16008
16009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
16010 {
16011 return qe_invalid;
16012 }
16013
16014
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(Header->zelda_version < 0x193)
16015 {
16016 if(!p_getc(&(temp_mapscr->old_cpage),f,true))
16017 {
16018 return qe_invalid;
16019 }
16020 }
16021
16022
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->undercset),f,true)) //recalculated for older quests
16023 {
16024 return qe_invalid;
16025 }
16026
16027
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16028 {
16029 return qe_invalid;
16030 }
16031
16032
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->flags),f,true))
16033 {
16034 return qe_invalid;
16035 }
16036
16037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->flags2),f,true))
16038 {
16039 return qe_invalid;
16040 }
16041
16042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->flags3),f,true))
16043 {
16044 return qe_invalid;
16045 }
16046
16047
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16048 //if (version>2)
16049 {
16050
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->flags4),f,true))
16051 {
16052 return qe_invalid;
16053 }
16054 98872 }
16055
16056
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16057 {
16058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->flags5),f,true))
16059 {
16060 return qe_invalid;
16061 }
16062
16063
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_igetw(&(temp_mapscr->noreset),f,true))
16064 {
16065 return qe_invalid;
16066 }
16067
16068
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
16069 {
16070 return qe_invalid;
16071 }
16072
16073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(temp_mapscr->flags5&32)
16074 {
16075 temp_mapscr->flags5 &= ~32;
16076 temp_mapscr->noreset |= 48;
16077 }
16078
16079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(version<8)
16080 {
16081 if(temp_mapscr->noreset&1)
16082 {
16083 temp_mapscr->noreset|=8192;
16084 }
16085
16086 if(temp_mapscr->nocarry&1)
16087 {
16088 temp_mapscr->nocarry|=8192;
16089 temp_mapscr->nocarry&=~1;
16090 }
16091 }
16092 98872 }
16093 else
16094 {
16095 temp_mapscr->flags5 = 0;
16096 temp_mapscr->noreset = 0;
16097 temp_mapscr->nocarry = 0;
16098 }
16099
16100
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16101 {
16102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->flags6),f,true))
16103 {
16104 return qe_invalid;
16105 }
16106 98872 }
16107
16108
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(version>5)
16109 {
16110
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->flags7),f,true))
16111 {
16112 return qe_invalid;
16113 }
16114
16115
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->flags8),f,true))
16116 {
16117 return qe_invalid;
16118 }
16119
16120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->flags9),f,true))
16121 {
16122 return qe_invalid;
16123 }
16124
16125
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->flags10),f,true))
16126 {
16127 return qe_invalid;
16128 }
16129
16130
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->csensitive),f,true))
16131 {
16132 return qe_invalid;
16133 }
16134 98872 }
16135 else
16136 {
16137 temp_mapscr->csensitive=1;
16138 }
16139
16140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(version<14) // August 2007: screen SFX added
16141 {
16142 if(temp_mapscr->flags&8) //fROAR
16143 {
16144 temp_mapscr->bosssfx=
16145 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16146 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16147 WAV_ROAR;
16148 }
16149
16150 if(temp_mapscr->flags&128) //fSEA
16151 {
16152 temp_mapscr->oceansfx=WAV_SEA;
16153 }
16154
16155 if(!(temp_mapscr->flags3&64)) //fNOSECRETSOUND
16156 {
16157 temp_mapscr->secretsfx=WAV_SECRET;
16158 }
16159
16160 temp_mapscr->flags3 &= ~66; //64|2
16161 temp_mapscr->flags2 &= ~32;
16162 temp_mapscr->flags &= ~136; // 128|8
16163 }
16164 else
16165 {
16166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
16167 {
16168 return qe_invalid;
16169 }
16170
16171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
16172 {
16173 return qe_invalid;
16174 }
16175
16176
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
16177 {
16178 return qe_invalid;
16179 }
16180 }
16181
16182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(version<15) // October 2007: another SFX
16183 {
16184 temp_mapscr->holdupsfx=WAV_PICKUP;
16185 }
16186 else
16187 {
16188
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
16189 {
16190 return qe_invalid;
16191 }
16192 }
16193
16194
16195
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16196 {
16197
2/2
✓ Branch 0 taken 593232 times.
✓ Branch 1 taken 98872 times.
692104 for(int32_t k=0; k<6; k++)
16198 {
16199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 593232 times.
593232 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
16200 {
16201 return qe_invalid;
16202 }
16203 593232 }
16204
16205
2/2
✓ Branch 0 taken 98872 times.
✓ Branch 1 taken 593232 times.
692104 for(int32_t k=0; k<6; k++)
16206 {
16207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 593232 times.
593232 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
16208 {
16209 return qe_invalid;
16210 }
16211 593232 }
16212 98872 }
16213 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16214 {
16215 if(!p_getc(&(temp_mapscr->layermap[2]),f,true))
16216 {
16217 return qe_invalid;
16218 }
16219
16220 if(!p_getc(&(temp_mapscr->layerscreen[2]),f,true))
16221 {
16222 return qe_invalid;
16223 }
16224
16225 if(!p_getc(&(temp_mapscr->layermap[4]),f,true))
16226 {
16227 return qe_invalid;
16228 }
16229
16230 if(!p_getc(&(temp_mapscr->layerscreen[4]),f,true))
16231
16232 {
16233 return qe_invalid;
16234 }
16235 }
16236
16237
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98872 if((Header->zelda_version == 0x192)&&(Header->build>149))
16238 {
16239 for(int32_t k=0; k<6; k++)
16240 {
16241 if(!p_getc(&tempbyte,f,true)) //layerxsize
16242 {
16243 return qe_invalid;
16244 }
16245 }
16246
16247 for(int32_t k=0; k<6; k++)
16248 {
16249 if(!p_getc(&tempbyte,f,true)) //layerxspeed
16250 {
16251 return qe_invalid;
16252 }
16253 }
16254
16255 for(int32_t k=0; k<6; k++)
16256 {
16257 if(!p_getc(&tempbyte,f,true)) //layerxdelay
16258 {
16259 return qe_invalid;
16260 }
16261 }
16262
16263 for(int32_t k=0; k<6; k++)
16264 {
16265 if(!p_getc(&tempbyte,f,true)) //layerysize
16266 {
16267 return qe_invalid;
16268 }
16269 }
16270
16271 for(int32_t k=0; k<6; k++)
16272 {
16273 if(!p_getc(&tempbyte,f,true)) //layeryspeed
16274 {
16275 return qe_invalid;
16276 }
16277 }
16278
16279 for(int32_t k=0; k<6; k++)
16280 {
16281 if(!p_getc(&tempbyte,f,true)) //layerydelay
16282 {
16283 return qe_invalid;
16284 }
16285 }
16286 }
16287
16288
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16289 {
16290
2/2
✓ Branch 0 taken 593232 times.
✓ Branch 1 taken 98872 times.
692104 for(int32_t k=0; k<6; k++)
16291 {
16292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 593232 times.
593232 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
16293 {
16294 return qe_invalid;
16295 }
16296 593232 }
16297 98872 }
16298
16299
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16300 {
16301
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98872 if((Header->zelda_version == 0x192)&&(Header->build>153))
16302 {
16303 if(!p_getc(&padding,f,true))
16304 {
16305 return qe_invalid;
16306 }
16307 }
16308
16309
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
16310 {
16311 return qe_invalid;
16312 }
16313 98872 }
16314
16315
2/6
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98872 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16316 {
16317 extras=15;
16318 }
16319
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98872 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16320 {
16321 extras=11;
16322 }
16323
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98872 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16324 {
16325 extras=32;
16326 }
16327
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98872 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16328 {
16329 extras=64;
16330 }
16331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 else if(Header->zelda_version < 0x193)
16332 {
16333 extras=62;
16334 }
16335 else
16336
16337 {
16338 98872 extras=0;
16339 }
16340
16341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 for(int32_t k=0; k<extras; k++)
16342 {
16343 if(!p_getc(&tempbyte,f,true)) //extra[k]
16344 {
16345 return qe_invalid;
16346 }
16347 }
16348
16349
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16350 //if (version>3)
16351 {
16352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_getc(&(temp_mapscr->nextmap),f,true))
16353 {
16354 return qe_invalid;
16355 }
16356
16357
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->nextscr),f,true))
16358 {
16359 return qe_invalid;
16360 }
16361 98872 }
16362 else
16363 {
16364 temp_mapscr->nextmap=0;
16365 temp_mapscr->nextscr=0;
16366 }
16367
16368
2/6
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98872 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16369 {
16370 secretcombos=20;
16371 }
16372
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98872 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16373 {
16374 secretcombos=256;
16375 }
16376 else
16377 {
16378 98872 secretcombos=128;
16379 }
16380
16381
2/6
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98872 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16382 {
16383 for(int32_t k=0; k<secretcombos; k++)
16384 {
16385 if(!p_getc(&tempbyte,f,true))
16386 {
16387 return qe_invalid;
16388 }
16389
16390 if(k<128)
16391 {
16392 temp_mapscr->secretcombo[k]=tempbyte;
16393 }
16394 }
16395 }
16396 else
16397 {
16398
2/2
✓ Branch 0 taken 12655616 times.
✓ Branch 1 taken 98872 times.
12754488 for(int32_t k=0; k<128; k++)
16399 {
16400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12655616 times.
12655616 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
16401 {
16402 return qe_invalid;
16403 }
16404
16405 12655616 }
16406 }
16407
16408
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16409 {
16410
2/2
✓ Branch 0 taken 12655616 times.
✓ Branch 1 taken 98872 times.
12754488 for(int32_t k=0; k<128; k++)
16411 {
16412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12655616 times.
12655616 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
16413 {
16414 return qe_invalid;
16415 }
16416 12655616 }
16417
16418
2/2
✓ Branch 0 taken 12655616 times.
✓ Branch 1 taken 98872 times.
12754488 for(int32_t k=0; k<128; k++)
16419 {
16420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12655616 times.
12655616 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
16421 {
16422 return qe_invalid;
16423 }
16424 12655616 }
16425 98872 }
16426
16427
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16428 {
16429 if(!p_getc(&padding,f,true))
16430 {
16431 return qe_invalid;
16432 }
16433 }
16434
16435 98872 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16436
16437
2/2
✓ Branch 0 taken 17401472 times.
✓ Branch 1 taken 98872 times.
17500344 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16438 {
16439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17401472 times.
17401472 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
16440 {
16441 return qe_invalid;
16442 }
16443 17401472 }
16444
16445
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16446 {
16447 if(!p_getc(&padding,f,true))
16448 {
16449 return qe_invalid;
16450 }
16451
16452 if(!p_getc(&padding,f,true))
16453 {
16454 return qe_invalid;
16455 }
16456 }
16457
16458
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16459 {
16460
2/2
✓ Branch 0 taken 17401472 times.
✓ Branch 1 taken 98872 times.
17500344 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16461 {
16462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17401472 times.
17401472 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
16463 {
16464 return qe_invalid;
16465 }
16466
16467
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17401472 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17401472 if((Header->zelda_version == 0x192)&&(Header->build<24))
16468 {
16469 if(!p_getc(&tempbyte,f,true))
16470 {
16471 return qe_invalid;
16472 }
16473
16474 if(!p_getc(&tempbyte,f,true))
16475 {
16476 return qe_invalid;
16477 }
16478
16479 if(!p_getc(&tempbyte,f,true))
16480 {
16481 return qe_invalid;
16482 }
16483 }
16484 17401472 }
16485 98872 }
16486
16487
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16488 {
16489
2/2
✓ Branch 0 taken 98872 times.
✓ Branch 1 taken 17401472 times.
17500344 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16490 {
16491
16492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17401472 times.
17401472 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
16493 {
16494 return qe_invalid;
16495 }
16496 17401472 }
16497 98872 }
16498
16499
2/6
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98872 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16500 {
16501 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16502 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16503 }
16504
16505
2/6
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98872 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16506 {
16507 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16508 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16509 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16510 temp_mapscr->secretcombo[sDINSFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16511 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16512 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16513 }
16514
16515
2/6
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98872 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98872 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16516 {
16517 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16518 {
16519 if((Header->zelda_version == 0x192)&&(Header->build>149))
16520 {
16521 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16522 {
16523 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16524 }
16525 }
16526 else
16527 {
16528 if((Header->zelda_version < 0x192)||
16529 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16530 {
16531 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16532 }
16533
16534 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16535 }
16536
16537 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16538 }
16539 }
16540
16541 /*if(version>12)
16542 {
16543 if(!p_getc(&(temp_mapscr->scrWidth),f,true))
16544 {
16545 return qe_invalid;
16546 }
16547 if(!p_getc(&(temp_mapscr->scrHeight),f,true))
16548 {
16549 return qe_invalid;
16550 }
16551 }*/
16552
16553
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(version>4)
16554 {
16555
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
16556 {
16557 return qe_invalid;
16558 }
16559 98872 }
16560 else
16561 {
16562 temp_mapscr->screen_midi = -1;
16563 }
16564
16565
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(version>=17)
16566 {
16567
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
16568 {
16569 return qe_invalid;
16570 }
16571 98872 }
16572 else
16573 {
16574 temp_mapscr->lens_layer = llNORMAL;
16575 }
16576
16577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(version>6)
16578 {
16579 dword bits;
16580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if(!p_igetl(&bits,f,true))
16581 {
16582 return qe_invalid;
16583 }
16584
16585 int32_t m;
16586 float tempfloat;
16587 word tempw;
16588
16589
2/2
✓ Branch 0 taken 98872 times.
✓ Branch 1 taken 3163904 times.
3262776 for(m=0; m<32; m++)
16590 {
16591 3163904 ffcdata& tempffc = temp_mapscr->ffcs[m];
16592 3163904 tempffc.clear();
16593
2/2
✓ Branch 0 taken 3156489 times.
✓ Branch 1 taken 7415 times.
3163904 if((bits>>m)&1)
16594 {
16595
1/2
✓ Branch 0 taken 7415 times.
✗ Branch 1 not taken.
7415 if(!p_igetw(&tempw,f,true))
16596 {
16597 return qe_invalid;
16598 }
16599 7415 tempffc.setData(tempw);
16600
16601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_getc(&(tempffc.cset),f,true))
16602 {
16603 return qe_invalid;
16604 }
16605
16606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_igetw(&(tempffc.delay),f,true))
16607 {
16608 return qe_invalid;
16609 }
16610
16611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(version < 9)
16612 {
16613 if(!p_igetf(&tempfloat,f,true))
16614 {
16615 return qe_invalid;
16616 }
16617
16618 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16619
16620 if(!p_igetf(&tempfloat,f,true))
16621 {
16622 return qe_invalid;
16623 }
16624
16625 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16626
16627 if(!p_igetf(&tempfloat,f,true))
16628 {
16629 return qe_invalid;
16630 }
16631
16632 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16633
16634 if(!p_igetf(&tempfloat,f,true))
16635 {
16636 return qe_invalid;
16637 }
16638
16639 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16640
16641 if(!p_igetf(&tempfloat,f,true))
16642 {
16643 return qe_invalid;
16644 }
16645
16646 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16647
16648 if(!p_igetf(&tempfloat,f,true))
16649 {
16650 return qe_invalid;
16651 }
16652
16653 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16654 }
16655 else
16656 {
16657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_igetzf(&(tempffc.x),f,true))
16658 {
16659 return qe_invalid;
16660 }
16661
16662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_igetzf(&(tempffc.y),f,true))
16663 {
16664 return qe_invalid;
16665 }
16666
16667
1/2
✓ Branch 0 taken 7415 times.
✗ Branch 1 not taken.
7415 if(!p_igetzf(&(tempffc.vx),f,true))
16668 {
16669 return qe_invalid;
16670 }
16671
16672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_igetzf(&(tempffc.vy),f,true))
16673 {
16674 return qe_invalid;
16675 }
16676
16677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_igetzf(&(tempffc.ax),f,true))
16678 {
16679 return qe_invalid;
16680 }
16681
16682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_igetzf(&(tempffc.ay),f,true))
16683 {
16684 return qe_invalid;
16685 }
16686 }
16687
16688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_getc(&(tempffc.link),f,true))
16689 {
16690 return qe_invalid;
16691 }
16692
16693
1/2
✓ Branch 0 taken 7415 times.
✗ Branch 1 not taken.
7415 if(version>7)
16694 {
16695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_getc(&tempbyte,f,true))
16696 {
16697 return qe_invalid;
16698 }
16699
16700 7415 tempffc.hxsz = (tempbyte&0x3F)+1;
16701 7415 tempffc.txsz = (tempbyte>>6)+1;
16702
16703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_getc(&tempbyte,f,true))
16704 {
16705 return qe_invalid;
16706 }
16707
16708 7415 tempffc.hysz = (tempbyte&0x3F)+1;
16709 7415 tempffc.tysz = (tempbyte>>6)+1;
16710
16711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_igetl(&(tempffc.flags),f,true))
16712 {
16713 return qe_invalid;
16714 }
16715 7415 }
16716 else
16717 {
16718 tempffc.hxsz=16;
16719 tempffc.hysz=16;
16720 tempffc.txsz=1;
16721 tempffc.tysz=1;
16722 tempffc.flags=0;
16723 }
16724
16725 7415 tempffc.updateSolid();
16726
16727
16728
3/6
✓ Branch 0 taken 7415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7415 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7415 times.
7415 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16729 {
16730 tempffc.flags|=ffIGNOREHOLDUP;
16731 }
16732
16733
1/2
✓ Branch 0 taken 7415 times.
✗ Branch 1 not taken.
7415 if(version>9)
16734 {
16735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_igetw(&(tempffc.script),f,true))
16736 {
16737 return qe_invalid;
16738 }
16739 7415 }
16740 else
16741 {
16742 tempffc.script=0;
16743 }
16744
16745
1/2
✓ Branch 0 taken 7415 times.
✗ Branch 1 not taken.
7415 if(version>10)
16746 {
16747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_igetl(&(tempffc.initd[0]),f,true))
16748 {
16749 return qe_invalid;
16750 }
16751
16752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_igetl(&(tempffc.initd[1]),f,true))
16753 {
16754 return qe_invalid;
16755 }
16756
16757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_igetl(&(tempffc.initd[2]),f,true))
16758 {
16759 return qe_invalid;
16760 }
16761
16762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_igetl(&(tempffc.initd[3]),f,true))
16763 {
16764 return qe_invalid;
16765 }
16766
16767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_igetl(&(tempffc.initd[4]),f,true))
16768 {
16769 return qe_invalid;
16770 }
16771
16772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_igetl(&(tempffc.initd[5]),f,true))
16773 {
16774 return qe_invalid;
16775 }
16776
16777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_igetl(&(tempffc.initd[6]),f,true))
16778 {
16779 return qe_invalid;
16780 }
16781
16782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_igetl(&(tempffc.initd[7]),f,true))
16783 {
16784 return qe_invalid;
16785 }
16786
16787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_getc(&(tempbyte),f,true))
16788 {
16789 return qe_invalid;
16790 }
16791
16792 7415 tempffc.inita[0]=tempbyte*10000;
16793
16794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7415 times.
7415 if(!p_getc(&(tempbyte),f,true))
16795 {
16796 return qe_invalid;
16797 }
16798
16799 7415 tempffc.inita[1]=tempbyte*10000;
16800 7415 }
16801 else
16802 {
16803 tempffc.inita[0] = 10000;
16804 tempffc.inita[1] = 10000;
16805 }
16806
16807 7415 tempffc.initialized = false;
16808
16809
1/2
✓ Branch 0 taken 7415 times.
✗ Branch 1 not taken.
7415 if(version <= 11)
16810 {
16811 fixffcs=true;
16812 }
16813 7415 }
16814 3163904 }
16815
16816 98872 }
16817
16818 //add in the new whistle flags
16819
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(version<13)
16820 {
16821 if(temp_mapscr->flags & fWHISTLE)
16822 {
16823 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16824 }
16825 }
16826
16827 // for(int32_t m=0; m<32; m++)
16828 // {
16829 // // ffcScriptData used to be part of mapscr, and this was handled just above
16830 // ffcScriptData[m].a[0] = 10000;
16831 // ffcScriptData[m].a[1] = 10000;
16832 // }
16833
16834 //2.55 starts here
16835
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98872 if ( version >= 19 && Header->zelda_version > 0x253 )
16836 {
16837 for ( int32_t q = 0; q < 10; q++ )
16838 {
16839 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
16840 {
16841 return qe_invalid;
16842 }
16843 }
16844 for ( int32_t q = 0; q < 10; q++ )
16845 {
16846 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
16847 {
16848 return qe_invalid;
16849 }
16850 }
16851 for ( int32_t q = 0; q < 10; q++ )
16852 {
16853 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
16854 {
16855 return qe_invalid;
16856 }
16857 }
16858 for ( int32_t q = 0; q < 10; q++ )
16859 {
16860 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
16861 {
16862 return qe_invalid;
16863 }
16864 }
16865 }
16866
2/4
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98872 times.
98872 if ( version < 19 && Header->zelda_version > 0x253 )
16867 {
16868 for ( int32_t q = 0; q < 10; q++ )
16869 {
16870 temp_mapscr->npcstrings[q] = 0;
16871 temp_mapscr->new_items[q] = 0;
16872 temp_mapscr->new_item_x[q] = 0;
16873 temp_mapscr->new_item_y[q] = 0;
16874 }
16875 }
16876
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98872 if ( version >= 20 && Header->zelda_version > 0x253 )
16877 {
16878 if(!p_igetw(&(temp_mapscr->script),f,true))
16879 {
16880 return qe_invalid;
16881 }
16882 for ( int32_t q = 0; q < 8; q++)
16883 {
16884 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
16885 {
16886 return qe_invalid;
16887 }
16888 }
16889 }
16890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
98872 if ( version < 20 )
16891 {
16892 98872 temp_mapscr->script = 0;
16893
2/2
✓ Branch 0 taken 790976 times.
✓ Branch 1 taken 98872 times.
889848 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16894 98872 }
16895
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98872 if ( version >= 21 && Header->zelda_version > 0x253 )
16896 {
16897 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
16898 {
16899 return qe_invalid;
16900 }
16901 }
16902
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if ( version < 21 )
16903 {
16904 98872 temp_mapscr->preloadscript = 0;
16905 98872 }
16906 //all builds with version > 20 need this. -Z
16907 98872 temp_mapscr->ffcswaitdraw = 0;
16908
16909
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98872 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16910 {
16911 if(!p_getc(&(temp_mapscr->hidelayers ),f,true))
16912 {
16913 return qe_invalid;
16914 }
16915 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f,true))
16916 {
16917 return qe_invalid;
16918 }
16919 }
16920
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if ( version < 22 )
16921 {
16922 98872 temp_mapscr->hidelayers = 0;
16923 98872 temp_mapscr->hidescriptlayers = 0;
16924 98872 }
16925
16926 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16927 //May be any version before 2.11. -Z
16928 /* --not the roar, the HIT SFX
16929 if ( Header->zelda_version <= 0x210 )
16930 {
16931 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16932 {
16933 temp_mapscr->bosssfx = WAV_ROAR;
16934 }
16935 }
16936 */
16937
16938 98872 return 0;
16939 98872 }
16940 99688 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
16941 {
16942
2/2
✓ Branch 0 taken 98872 times.
✓ Branch 1 taken 816 times.
99688 if(version < 23)
16943 {
16944 98872 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
16945
1/2
✓ Branch 0 taken 98872 times.
✗ Branch 1 not taken.
98872 if(ret) return ret;
16946 98872 temp_mapscr->update_ffc_count(31);
16947 98872 }
16948 else
16949 {
16950
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&(temp_mapscr->valid),f,true))
16951 return qe_invalid;
16952
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 769 times.
816 if(!(temp_mapscr->valid & mVALID))
16953 769 return 0; //Empty screen
16954 uint32_t scr_has_flags;
16955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(!p_igetl(&scr_has_flags,f,true))
16956 return qe_invalid;
16957
16958
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(scr_has_flags & SCRHAS_ROOMDATA)
16959 {
16960 if(!p_getc(&(temp_mapscr->guy),f,true))
16961 return qe_invalid;
16962 if(!p_igetw(&(temp_mapscr->str),f,true))
16963 return qe_invalid;
16964 if(!p_getc(&(temp_mapscr->room),f,true))
16965 return qe_invalid;
16966 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16967 return qe_invalid;
16968 }
16969
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 1 times.
47 if(scr_has_flags & SCRHAS_ITEM)
16970 {
16971
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&(temp_mapscr->item),f,true))
16972 return qe_invalid;
16973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!p_getc(&(temp_mapscr->hasitem),f,true))
16974 return qe_invalid;
16975
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&(temp_mapscr->itemx),f,true))
16976 return qe_invalid;
16977
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&(temp_mapscr->itemy),f,true))
16978 return qe_invalid;
16979 1 }
16980
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 5 times.
47 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16981 {
16982
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
16983 return qe_invalid;
16984 5 }
16985
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 1 times.
47 if(scr_has_flags & SCRHAS_TWARP)
16986 {
16987
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
16988 {
16989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
16990 return qe_invalid;
16991 4 }
16992
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
16993 {
16994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
16995 return qe_invalid;
16996 4 }
16997
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
16998 {
16999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
17000 return qe_invalid;
17001 4 }
17002
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
17003 return qe_invalid;
17004 1 }
17005
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 4 times.
47 if(scr_has_flags & SCRHAS_SWARP)
17006 {
17007
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<4; i++)
17008 {
17009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
17010 return qe_invalid;
17011 16 }
17012
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<4; i++)
17013 {
17014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
17015 return qe_invalid;
17016 16 }
17017
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<4; i++)
17018 {
17019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
17020 return qe_invalid;
17021 16 }
17022
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
17023 return qe_invalid;
17024
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
17025 return qe_invalid;
17026 4 }
17027
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 8 times.
47 if(scr_has_flags & SCRHAS_WARPRET)
17028 {
17029
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 8 times.
40 for(int32_t i=0; i<4; i++)
17030 {
17031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
17032 return qe_invalid;
17033 32 }
17034
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 8 times.
40 for(int32_t i=0; i<4; i++)
17035 {
17036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
17037 return qe_invalid;
17038 32 }
17039
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
17040 return qe_invalid;
17041
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
17042 return qe_invalid;
17043 8 }
17044
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 38 times.
47 if(scr_has_flags & SCRHAS_LAYERS)
17045 {
17046
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 9 times.
63 for(int32_t k=0; k<6; k++)
17047 {
17048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
17049 return qe_invalid;
17050 54 }
17051
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 9 times.
63 for(int32_t k=0; k<6; k++)
17052 {
17053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
17054 return qe_invalid;
17055 54 }
17056
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 9 times.
63 for(int32_t k=0; k<6; k++)
17057 {
17058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
17059 return qe_invalid;
17060 54 }
17061
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&(temp_mapscr->hidelayers),f,true))
17062 return qe_invalid;
17063
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&(temp_mapscr->hidescriptlayers),f,true))
17064 return qe_invalid;
17065 9 }
17066 else
17067 {
17068
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 38 times.
266 for(int32_t k=0; k<6; k++)
17069 {
17070 228 temp_mapscr->layeropacity[k] = 255;
17071 228 }
17072 }
17073
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(scr_has_flags & SCRHAS_MAZE)
17074 {
17075 for(int32_t k=0; k<4; k++)
17076 {
17077 if(!p_getc(&(temp_mapscr->path[k]),f,true))
17078 return qe_invalid;
17079 }
17080 if(!p_getc(&(temp_mapscr->exitdir),f,true))
17081 return qe_invalid;
17082 }
17083
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 12 times.
47 if(scr_has_flags & SCRHAS_D_S_U)
17084 {
17085
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
17086 return qe_invalid;
17087
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
60 for(int32_t k=0; k<4; k++)
17088 {
17089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!p_getc(&(temp_mapscr->door[k]),f,true))
17090 return qe_invalid;
17091 48 }
17092
17093
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&(temp_mapscr->stairx),f,true))
17094 return qe_invalid;
17095
17096
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&(temp_mapscr->stairy),f,true))
17097 return qe_invalid;
17098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
17099 return qe_invalid;
17100
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&(temp_mapscr->undercset),f,true))
17101 return qe_invalid;
17102 12 }
17103
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 15 times.
47 if(scr_has_flags & SCRHAS_FLAGS)
17104 {
17105
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags),f,true))
17106 return qe_invalid;
17107
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags2),f,true))
17108 return qe_invalid;
17109
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags3),f,true))
17110 return qe_invalid;
17111
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags4),f,true))
17112 return qe_invalid;
17113
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags5),f,true))
17114 return qe_invalid;
17115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(!p_getc(&(temp_mapscr->flags6),f,true))
17116 return qe_invalid;
17117
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags7),f,true))
17118 return qe_invalid;
17119
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags8),f,true))
17120 return qe_invalid;
17121
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags9),f,true))
17122 return qe_invalid;
17123
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(!p_getc(&(temp_mapscr->flags10),f,true))
17124 return qe_invalid;
17125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
17126 return qe_invalid;
17127 15 }
17128
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 3 times.
47 if(scr_has_flags & SCRHAS_ENEMY)
17129 {
17130
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 3 times.
33 for(int32_t k=0; k<10; k++)
17131 {
17132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
17133 return qe_invalid;
17134
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17135 temp_mapscr->enemy[k] = 0;
17136 30 }
17137
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&(temp_mapscr->pattern),f,true))
17138 return qe_invalid;
17139 3 }
17140
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(scr_has_flags & SCRHAS_CARRY)
17141 {
17142 if(!p_igetw(&(temp_mapscr->noreset),f,true))
17143 return qe_invalid;
17144 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
17145 return qe_invalid;
17146 if(!p_getc(&(temp_mapscr->nextmap),f,true))
17147 return qe_invalid;
17148 if(!p_getc(&(temp_mapscr->nextscr),f,true))
17149 return qe_invalid;
17150 }
17151
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(scr_has_flags & SCRHAS_SCRIPT)
17152 {
17153 if(!p_igetw(&(temp_mapscr->script),f,true))
17154 return qe_invalid;
17155 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17156 return qe_invalid;
17157 for ( int32_t q = 0; q < 8; q++ )
17158 {
17159 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17160 return qe_invalid;
17161 }
17162 }
17163
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(scr_has_flags & SCRHAS_UNUSED)
17164 {
17165 for ( int32_t q = 0; q < 10; q++ )
17166 {
17167 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17168 return qe_invalid;
17169 }
17170 for ( int32_t q = 0; q < 10; q++ )
17171 {
17172 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17173 return qe_invalid;
17174 }
17175 for ( int32_t q = 0; q < 10; q++ )
17176 {
17177 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17178 return qe_invalid;
17179 }
17180 for ( int32_t q = 0; q < 10; q++ )
17181 {
17182 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17183 return qe_invalid;
17184 }
17185 }
17186
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 12 times.
47 if(scr_has_flags & SCRHAS_SECRETS)
17187 {
17188
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 12 times.
1548 for(int32_t k=0; k<128; k++)
17189 {
17190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
17191 return qe_invalid;
17192 1536 }
17193
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 12 times.
1548 for(int32_t k=0; k<128; k++)
17194 {
17195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
17196 return qe_invalid;
17197 1536 }
17198
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 12 times.
1548 for(int32_t k=0; k<128; k++)
17199 {
17200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
17201 return qe_invalid;
17202 1536 }
17203 12 }
17204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(scr_has_flags & SCRHAS_COMBOFLAG)
17205 {
17206
2/2
✓ Branch 0 taken 8272 times.
✓ Branch 1 taken 47 times.
8319 for(int32_t k=0; k<176; ++k)
17207 {
17208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8272 times.
8272 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
17209 return qe_invalid;
17210 8272 }
17211
2/2
✓ Branch 0 taken 8272 times.
✓ Branch 1 taken 47 times.
8319 for(int32_t k=0; k<176; ++k)
17212 {
17213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8272 times.
8272 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
17214 return qe_invalid;
17215 8272 }
17216
2/2
✓ Branch 0 taken 8272 times.
✓ Branch 1 taken 47 times.
8319 for(int32_t k=0; k<176; ++k)
17217 {
17218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8272 times.
8272 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
17219 return qe_invalid;
17220 8272 }
17221 47 }
17222
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(scr_has_flags & SCRHAS_MISC)
17223 {
17224
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(!p_igetw(&(temp_mapscr->color),f,true))
17225 return qe_invalid;
17226
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(!p_getc(&(temp_mapscr->csensitive),f,true))
17227 return qe_invalid;
17228
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
17229 return qe_invalid;
17230
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
17231 return qe_invalid;
17232
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
17233 return qe_invalid;
17234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
17235 return qe_invalid;
17236
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
17237 return qe_invalid;
17238
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
17239 return qe_invalid;
17240
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
17241 return qe_invalid;
17242 47 }
17243 else
17244 {
17245 temp_mapscr->screen_midi = -1;
17246 temp_mapscr->csensitive = 1;
17247 }
17248 //FFC
17249 47 bool old_ff = version < 25;
17250 47 dword bits = 0;
17251 47 word numffc = 32;
17252
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 25 times.
47 if(old_ff)
17253 {
17254
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&bits,f,true))
17255 return qe_invalid;
17256 22 }
17257 else
17258 {
17259
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&numffc,f,true))
17260 return qe_invalid;
17261 }
17262 byte tempbyte;
17263 word tempw;
17264
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
47 static ffcdata nil_ffc;
17265
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 1013 times.
1060 for(word m = 0; m < numffc; ++m)
17266 {
17267
1/2
✓ Branch 0 taken 1013 times.
✗ Branch 1 not taken.
1013 ffcdata& tempffc = (m < MAXFFCS)
17268 1013 ? temp_mapscr->ffcs[m]
17269 : nil_ffc; //sanity
17270 1013 tempffc.clear();
17271
3/4
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 704 times.
1013 if(old_ff && !(bits & (1<<m))) continue;
17272
17273
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if(!p_igetw(&tempw,f,true))
17274 return qe_invalid;
17275
3/4
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 267 times.
309 if(!old_ff && !tempw) //empty ffc, nothing more to load
17276 267 continue;
17277 42 tempffc.setData(tempw);
17278
17279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_getc(&(tempffc.cset),f,true))
17280 return qe_invalid;
17281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetw(&(tempffc.delay),f,true))
17282 return qe_invalid;
17283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetzf(&(tempffc.x),f,true))
17284 return qe_invalid;
17285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetzf(&(tempffc.y),f,true))
17286 return qe_invalid;
17287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetzf(&(tempffc.vx),f,true))
17288 return qe_invalid;
17289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetzf(&(tempffc.vy),f,true))
17290 return qe_invalid;
17291
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_igetzf(&(tempffc.ax),f,true))
17292 return qe_invalid;
17293
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_igetzf(&(tempffc.ay),f,true))
17294 return qe_invalid;
17295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_getc(&(tempffc.link),f,true))
17296 return qe_invalid;
17297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(version < 24)
17298 {
17299 if(!p_getc(&tempbyte,f,true))
17300 return qe_invalid;
17301 tempffc.hxsz = (tempbyte&0x3F)+1;
17302 tempffc.txsz = (tempbyte>>6)+1;
17303 if(!p_getc(&tempbyte,f,true))
17304 return qe_invalid;
17305 tempffc.hysz = (tempbyte&0x3F)+1;
17306 tempffc.tysz = (tempbyte>>6)+1;
17307 }
17308 else
17309 {
17310
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_igetl(&(tempffc.hxsz),f,true))
17311 return qe_invalid;
17312
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_igetl(&(tempffc.hysz),f,true))
17313 return qe_invalid;
17314
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_getc(&(tempffc.txsz),f,true))
17315 return qe_invalid;
17316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_getc(&(tempffc.tysz),f,true))
17317 return qe_invalid;
17318 }
17319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetl(&(tempffc.flags),f,true))
17320 return qe_invalid;
17321 42 tempffc.updateSolid();
17322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetw(&(tempffc.script),f,true))
17323 return qe_invalid;
17324
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 42 times.
378 for(auto q = 0; q < 8; ++q)
17325 {
17326
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_igetl(&(tempffc.initd[q]),f,true))
17327 return qe_invalid;
17328 336 }
17329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_getc(&(tempbyte),f,true))
17330 return qe_invalid;
17331 42 tempffc.inita[0]=tempbyte*10000;
17332
17333
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_getc(&(tempbyte),f,true))
17334 return qe_invalid;
17335 42 tempffc.inita[1]=tempbyte*10000;
17336
17337 42 tempffc.initialized = false;
17338 42 }
17339
2/2
✓ Branch 0 taken 5003 times.
✓ Branch 1 taken 47 times.
5050 for(word m = numffc; m < MAXFFCS; ++m)
17340 {
17341 5003 temp_mapscr->ffcs[m].clear();
17342 5003 }
17343 47 temp_mapscr->update_ffc_count(numffc-1);
17344 //END FFC
17345 }
17346 98919 return 0;
17347 99688 }
17348
17349
17350 62 int32_t readmaps(PACKFILE *f, zquestheader *Header, bool keepdata)
17351 {
17352 62 int32_t scr=0;
17353
17354 62 word version=0;
17355 dword dummy;
17356 int32_t screens_to_read;
17357
17358 62 mapscr temp_mapscr;
17359 zcmap temp_map;
17360 word temp_map_count;
17361 dword section_size;
17362
17363
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17364 {
17365 screens_to_read=MAPSCRS192b136;
17366 }
17367 else
17368 {
17369 62 screens_to_read=MAPSCRS;
17370 }
17371
17372
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(Header->zelda_version > 0x192)
17373 {
17374 //section version info
17375
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&version,f,true))
17376 {
17377 return qe_invalid;
17378 }
17379
17380 62 FFCore.quest_format[vMaps] = version;
17381
17382 //al_trace("Maps version %d\n", version);
17383
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&dummy,f,true))
17384 {
17385 return qe_invalid;
17386 }
17387
17388 //section size
17389
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetl(&section_size,f,true))
17390 {
17391 return qe_invalid;
17392 }
17393
17394 //finally... section data
17395
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_map_count,f,true))
17396 {
17397 return 5;
17398 }
17399 62 }
17400 else
17401 {
17402 temp_map_count=map_count;
17403 }
17404
17405
17406
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(keepdata)
17407 {
17408 62 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17409
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 TheMaps.resize(_mapsSize);
17410
17411
2/2
✓ Branch 0 taken 99688 times.
✓ Branch 1 taken 62 times.
99750 for(int32_t i(0); i<_mapsSize; i++)
17412
1/2
✓ Branch 0 taken 99688 times.
✗ Branch 1 not taken.
99688 TheMaps[i].zero_memory();
17413
17414 // Used to be done for each screen
17415
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 62 times.
7998 for(int32_t i=0; i<MAXFFCS; i++)
17416 {
17417 7936 ffcScriptData[i].a[0] = 10000;
17418 7936 ffcScriptData[i].a[1] = 10000;
17419 7936 }
17420
17421 62 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17422 62 }
17423
17424
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 temp_mapscr.zero_memory();
17425
17426 62 memset(&temp_map, 0, sizeof(zcmap));
17427 62 temp_map.scrResWidth = 256;
17428 62 temp_map.scrResHeight = 224;
17429 62 temp_map.tileWidth = 16;
17430 62 temp_map.tileHeight = 11;
17431 62 temp_map.viewWidth = 256;
17432 62 temp_map.viewHeight = 176;
17433 62 temp_map.viewX = 0;
17434 62 temp_map.viewY = 64;
17435 62 temp_map.subaWidth = 256;
17436 62 temp_map.subaHeight = 168;
17437 62 temp_map.subaTrans = false;
17438 62 temp_map.subpWidth = 256;
17439 62 temp_map.subpHeight = 56;
17440 62 temp_map.subpTrans = false;
17441
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 733 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 733 times.
795 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17442 {
17443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 733 times.
733 if(keepdata==true) //!TODO Trim fully
17444 {
17445 733 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17446 733 }
17447 733 byte valid=1;
17448
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 727 times.
733 if(version > 22)
17449 {
17450
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_getc(&valid,f,true))
17451 return qe_invalid;
17452 6 }
17453
2/2
✓ Branch 0 taken 99688 times.
✓ Branch 1 taken 733 times.
100421 for(int32_t j=0; j<screens_to_read; j++)
17454 {
17455 99688 scr=i*MAPSCRS+j;
17456
1/2
✓ Branch 0 taken 99688 times.
✗ Branch 1 not taken.
99688 clear_screen(&temp_mapscr);
17457
1/2
✓ Branch 0 taken 99688 times.
✗ Branch 1 not taken.
99688 if(valid)
17458
1/2
✓ Branch 0 taken 99688 times.
✗ Branch 1 not taken.
99688 readmapscreen(f, Header, &temp_mapscr, &temp_map, version);
17459
17460
1/2
✓ Branch 0 taken 99688 times.
✗ Branch 1 not taken.
99688 if(keepdata==true)
17461 {
17462
1/2
✓ Branch 0 taken 99688 times.
✗ Branch 1 not taken.
99688 TheMaps[scr] = temp_mapscr;
17463 99688 }
17464 99688 }
17465
17466
1/2
✓ Branch 0 taken 733 times.
✗ Branch 1 not taken.
733 if(keepdata==true)
17467 {
17468
2/6
✓ Branch 0 taken 733 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 733 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
733 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17469 {
17470 int32_t index = (i*MAPSCRS+132);
17471
17472 TheMaps[index]=TheMaps[index-1];
17473
17474 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17475 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17476 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17477
17478 for(int32_t j=133; j<MAPSCRS; j++)
17479 {
17480 scr=i*MAPSCRS+j;
17481
17482 TheMaps[scr].zero_memory();
17483 TheMaps[scr].valid = mVERSION;
17484 TheMaps[scr].screen_midi = -1;
17485 TheMaps[scr].csensitive = 1;
17486 }
17487 }
17488
17489
2/6
✓ Branch 0 taken 733 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 733 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
733 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17490 {
17491 for(int32_t j=0; j<MAPSCRS; j++)
17492 {
17493 scr=i*MAPSCRS+j;
17494 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17495
17496 for(int32_t k=0; k<128; k++)
17497 {
17498 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17499 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17500 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17501 }
17502 }
17503 }
17504 733 }
17505 733 }
17506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata)
17507 {
17508 62 map_count = temp_map_count;
17509 62 }
17510
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 clear_screen(&temp_mapscr);
17511 62 return 0;
17512 62 }
17513
17514
17515 59 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos, bool keepdata)
17516 {
17517 59 reset_combo_animations();
17518 59 reset_combo_animations2();
17519
17520 59 init_combo_classes();
17521
17522 // combos
17523 59 word combos_used=0;
17524 int32_t dummy;
17525 byte padding;
17526 59 newcombo temp_combo;
17527 //word section_cversion=0;
17528
17529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(keepdata==true)
17530 {
17531
2/2
✓ Branch 0 taken 3851520 times.
✓ Branch 1 taken 59 times.
3851579 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17532 3851520 combobuf[q].clear();
17533 59 }
17534
17535 // if(version > 0x192)
17536 // {
17537 // //section version info
17538 // if(!p_igetw(&section_version,f,true))
17539 // {
17540 // return qe_invalid;
17541 // }
17542
17543 // FFCore.quest_format[vCombos] = section_version;
17544
17545 // //al_trace("Combos version %d\n", section_version);
17546 // if(!p_igetw(&section_cversion,f,true))
17547 // {
17548 // return qe_invalid;
17549 // }
17550
17551 // //section size
17552 // if(!p_igetl(&dummy,f,true))
17553 // {
17554 // return qe_invalid;
17555 // }
17556 // }
17557
17558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(version < 0x174)
17559 {
17560 combos_used=1024;
17561 }
17562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 else if(version < 0x191)
17563 {
17564 combos_used=2048;
17565 }
17566 else
17567 {
17568
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&combos_used,f,true))
17569 {
17570 return qe_invalid;
17571 }
17572 }
17573
17574 //finally... section data
17575
2/2
✓ Branch 0 taken 147094 times.
✓ Branch 1 taken 59 times.
147153 for(int32_t i=0; i<combos_used; i++)
17576 {
17577 147094 temp_combo.clear();
17578
17579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if ( section_version >= 11 )
17580 {
17581 if(!p_igetl(&temp_combo.tile,f,true))
17582 {
17583 return qe_invalid;
17584 }
17585 }
17586 else
17587 {
17588
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(!p_igetw(&temp_combo.tile,f,true))
17589 {
17590 return qe_invalid;
17591 }
17592 }
17593 147094 temp_combo.o_tile = temp_combo.tile;
17594
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(!p_getc(&temp_combo.flip,f,true))
17595 {
17596 return qe_invalid;
17597 }
17598
17599
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(!p_getc(&temp_combo.walk,f,true))
17600 {
17601 return qe_invalid;
17602 }
17603
17604
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(!p_getc(&temp_combo.type,f,true))
17605 {
17606 return qe_invalid;
17607 }
17608
17609
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(!p_getc(&temp_combo.csets,f,true))
17610 {
17611 return qe_invalid;
17612 }
17613
17614
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(version < 0x193)
17615 {
17616 if(!p_getc(&padding,f,true))
17617 {
17618 return qe_invalid;
17619 }
17620
17621 if(!p_getc(&padding,f,true))
17622 {
17623 return qe_invalid;
17624 }
17625
17626 if(version < 0x192)
17627 {
17628 if(version == 0x191)
17629 {
17630 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17631 {
17632 if(!p_getc(&padding,f,true))
17633 {
17634 return qe_invalid;
17635 }
17636 }
17637 }
17638
17639 if(keepdata==true)
17640 {
17641 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
17642 }
17643
17644 continue;
17645 }
17646 }
17647
17648
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(!p_getc(&temp_combo.frames,f,true))
17649 {
17650 return qe_invalid;
17651 }
17652
17653
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(!p_getc(&temp_combo.speed,f,true))
17654 {
17655 return qe_invalid;
17656 }
17657
17658
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(!p_igetw(&temp_combo.nextcombo,f,true))
17659 {
17660 return qe_invalid;
17661 }
17662
17663
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(!p_getc(&temp_combo.nextcset,f,true))
17664 {
17665 return qe_invalid;
17666 }
17667
17668 //Base flag
17669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version>=3)
17670 {
17671
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(!p_getc(&temp_combo.flag,f,true))
17672 {
17673 return qe_invalid;
17674 }
17675 147094 }
17676
17677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version>=4)
17678 {
17679
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(!p_getc(&temp_combo.skipanim,f,true))
17680 {
17681 return qe_invalid;
17682 }
17683
17684
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(!p_igetw(&temp_combo.nexttimer,f,true))
17685 {
17686 return qe_invalid;
17687 }
17688 147094 }
17689
17690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version>=5)
17691 {
17692
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(!p_getc(&temp_combo.skipanimy,f,true))
17693 {
17694 return qe_invalid;
17695 }
17696 147094 }
17697
17698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version>=6)
17699 {
17700
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(!p_getc(&temp_combo.animflags,f,true))
17701 {
17702 return qe_invalid;
17703 }
17704
17705
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(section_version == 6)
17706 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17707 147094 }
17708
17709
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(section_version>=8) //combo Attributes[4] and userflags.
17710 {
17711 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17712 {
17713 if(!p_igetl(&temp_combo.attributes[q],f,true))
17714 {
17715 return qe_invalid;
17716 }
17717 }
17718 if(!p_igetl(&temp_combo.usrflags,f,true))
17719 {
17720 return qe_invalid;
17721 }
17722 if(section_version >= 20)
17723 {
17724 if(!p_igetw(&temp_combo.genflags,f,true))
17725 {
17726 return qe_invalid;
17727 }
17728 }
17729 else
17730 {
17731 temp_combo.genflags = 0;
17732 switch(temp_combo.type)
17733 {
17734 case cPUSH_WAIT: case cPUSH_HEAVY:
17735 case cPUSH_HW: case cL_STATUE:
17736 case cR_STATUE: case cPUSH_HEAVY2:
17737 case cPUSH_HW2: case cPOUND:
17738 case cC_STATUE: case cMIRROR:
17739 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17740 case cMAGICPRISM: case cMAGICPRISM4:
17741 case cMAGICSPONGE: case cEYEBALL_A:
17742 case cEYEBALL_B: case cEYEBALL_4:
17743 case cBUSH: case cFLOWERS:
17744 case cLOCKBLOCK: case cLOCKBLOCK2:
17745 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17746 case cCHEST: case cCHEST2:
17747 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17748 case cBOSSCHEST: case cBOSSCHEST2:
17749 case cBUSHNEXT: case cBUSHTOUCHY:
17750 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17751 case cSIGNPOST: case cCSWITCHBLOCK:
17752 case cTORCH: case cTRIGGERGENERIC:
17753 if(temp_combo.usrflags & cflag16)
17754 {
17755 temp_combo.genflags |= cflag1;
17756 temp_combo.usrflags &= ~cflag16;
17757 }
17758 break; }
17759 }
17760 }
17761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version>=10) //combo trigger flags
17762 {
17763 for ( int32_t q = 0; q < 3; q++ )
17764 {
17765 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17766 {
17767 return qe_invalid;
17768 }
17769 }
17770 }
17771
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17772 {
17773 for ( int32_t q = 0; q < 2; q++ )
17774 {
17775 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17776 {
17777 return qe_invalid;
17778 }
17779 }
17780 }
17781
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(section_version >= 9)
17782 {
17783 if(!p_igetl(&temp_combo.triggerlevel,f,true))
17784 {
17785 return qe_invalid;
17786 }
17787 }
17788
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(section_version >= 22)
17789 {
17790 if(!p_getc(&temp_combo.triggerbtn,f,true))
17791 {
17792 return qe_invalid;
17793 }
17794 }
17795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version < 23)
17796 {
17797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17798 {
17799 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17800 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17801 case cTRIGGERGENERIC: case cCSWITCH:
17802 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17803 }
17804 147094 }
17805
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(section_version >= 24)
17806 {
17807 if(!p_getc(&temp_combo.triggeritem,f,true))
17808 {
17809 return qe_invalid;
17810 }
17811 if(!p_getc(&temp_combo.trigtimer,f,true))
17812 {
17813 return qe_invalid;
17814 }
17815 }
17816
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(section_version >= 25)
17817 {
17818 if(!p_getc(&temp_combo.trigsfx,f,true))
17819 {
17820 return qe_invalid;
17821 }
17822 }
17823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version >= 27)
17824 {
17825 if(!p_igetl(&temp_combo.trigchange,f,true))
17826 {
17827 return qe_invalid;
17828 }
17829 }
17830 else
17831 {
17832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17833 temp_combo.trigchange = 1;
17834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17835 temp_combo.trigchange = -1;
17836 147094 else temp_combo.trigchange = 0;
17837 147094 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17838 }
17839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version >= 29)
17840 {
17841 if(!p_igetw(&temp_combo.trigprox,f,true))
17842 {
17843 return qe_invalid;
17844 }
17845 if(!p_getc(&temp_combo.trigctr,f,true))
17846 {
17847 return qe_invalid;
17848 }
17849 if(!p_igetl(&temp_combo.trigctramnt,f,true))
17850 {
17851 return qe_invalid;
17852 }
17853 }
17854 else
17855 {
17856 147094 temp_combo.trigprox = 0;
17857 147094 temp_combo.trigctr = 0;
17858 147094 temp_combo.trigctramnt = 0;
17859 }
17860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version >= 30)
17861 {
17862 if(!p_getc(&temp_combo.triglbeam,f,true))
17863 {
17864 return qe_invalid;
17865 }
17866 }
17867 147094 else temp_combo.triglbeam = 0;
17868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version >= 31)
17869 {
17870 if(!p_getc(&temp_combo.trigcschange,f,true))
17871 {
17872 return qe_invalid;
17873 }
17874 if(!p_igetw(&temp_combo.spawnitem,f,true))
17875 {
17876 return qe_invalid;
17877 }
17878 if(!p_igetw(&temp_combo.spawnenemy,f,true))
17879 {
17880 return qe_invalid;
17881 }
17882 if(!p_getc(&temp_combo.exstate,f,true))
17883 {
17884 return qe_invalid;
17885 }
17886 if(!p_igetl(&temp_combo.spawnip,f,true))
17887 {
17888 return qe_invalid;
17889 }
17890 if(!p_getc(&temp_combo.trigcopycat,f,true))
17891 {
17892 return qe_invalid;
17893 }
17894 }
17895 else
17896 {
17897 147094 temp_combo.trigcschange = 0;
17898 147094 temp_combo.spawnitem = 0;
17899 147094 temp_combo.spawnenemy = 0;
17900 147094 temp_combo.exstate = -1;
17901 147094 temp_combo.spawnip = 0;
17902 147094 temp_combo.trigcopycat = 0;
17903 }
17904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version >= 32)
17905 {
17906 if(!p_getc(&temp_combo.trigcooldown,f,true))
17907 {
17908 return qe_invalid;
17909 }
17910 }
17911 else
17912 {
17913 147094 temp_combo.trigcooldown = 0;
17914 }
17915
17916
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(section_version>=12) //combo label
17917 {
17918 for ( int32_t q = 0; q < 11; q++ )
17919 {
17920 if(!p_getc(&temp_combo.label[q],f,true))
17921 {
17922 return qe_invalid;
17923 }
17924 }
17925 }
17926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version<12) //combo label
17927 {
17928
2/2
✓ Branch 0 taken 1618034 times.
✓ Branch 1 taken 147094 times.
1765128 for ( int32_t q = 0; q < 11; q++ )
17929 {
17930 1618034 temp_combo.label[q] = 0;
17931 1618034 }
17932 147094 }
17933 //al_trace("Read combo label\n");
17934
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(section_version>=13) //attribytes[4]
17935 {
17936 for ( int32_t q = 0; q < 4; q++ ) //Bad Zoria, don't mix constants with hardcodes
17937 {
17938 if(!p_getc(&temp_combo.attribytes[q],f,true))
17939 {
17940 return qe_invalid;
17941 }
17942 }
17943
17944 }
17945 //al_trace("Read combo attribytes\n");
17946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if( section_version < 13 )
17947 {
17948
2/2
✓ Branch 0 taken 588376 times.
✓ Branch 1 taken 147094 times.
735470 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17949 {
17950 588376 temp_combo.attribytes[q] = 0;
17951 588376 }
17952
17953 147094 }
17954 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17955 * This fixes a poor implementation of a ->next flag bug thing.
17956 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17957 * there was a version bump a few weeks before a change that broke stuff.
17958 */
17959
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147094 if (section_version >= 13 && section_version < 21)
17960 {
17961 set_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17962 }
17963 //combo scripts
17964
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(section_version>=14)
17965 {
17966 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
17967 for ( int32_t q = 0; q < 2; q++ )
17968 {
17969 if(!p_igetl(&temp_combo.initd[q],f,true))
17970 {
17971 return qe_invalid;
17972 }
17973 }
17974
17975 }
17976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version<14)
17977 {
17978 147094 temp_combo.script = 0;
17979
2/2
✓ Branch 0 taken 294188 times.
✓ Branch 1 taken 147094 times.
441282 for ( int32_t q = 0; q < 2; q++ )
17980 {
17981 294188 temp_combo.initd[q] = 0;
17982 294188 }
17983 147094 }
17984 //al_trace("Read combo script data\n");
17985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version>=15)
17986 {
17987 if(!p_igetl(&temp_combo.o_tile,f,true)) return qe_invalid;
17988 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17989 if(!p_getc(&temp_combo.cur_frame,f,true)) return qe_invalid;
17990 if(!p_getc(&temp_combo.aclk,f,true)) return qe_invalid;
17991 }
17992 else
17993 {
17994 147094 temp_combo.o_tile = temp_combo.tile;
17995 147094 temp_combo.cur_frame = 0;
17996 147094 temp_combo.aclk = 0;
17997 }
17998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version>=17) //attribytes[4]
17999 {
18000 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
18001 {
18002 if(!p_getc(&temp_combo.attribytes[q],f,true))
18003 {
18004 return qe_invalid;
18005 }
18006 }
18007 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
18008 {
18009 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18010 {
18011 return qe_invalid;
18012 }
18013 }
18014
18015 }
18016 else
18017 {
18018
2/2
✓ Branch 0 taken 588376 times.
✓ Branch 1 taken 147094 times.
735470 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
18019 {
18020 588376 temp_combo.attribytes[q] = 0;
18021 588376 }
18022
2/2
✓ Branch 0 taken 1176752 times.
✓ Branch 1 taken 147094 times.
1323846 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
18023 {
18024 1176752 temp_combo.attrishorts[q] = 0;
18025 1176752 }
18026 }
18027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version<18) //upper bits for .walk
18028 {
18029 147094 temp_combo.walk |= 0xF0; //All on by default for old quests -E
18030 147094 }
18031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version < 19)
18032 {
18033
2/2
✓ Branch 0 taken 588376 times.
✓ Branch 1 taken 147094 times.
735470 for(int32_t q = 0; q < 4; ++q)
18034 {
18035 588376 temp_combo.attributes[q] *= 10000L;
18036 588376 }
18037 147094 }
18038
18039
1/2
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
147094 if(version < 0x193)
18040 {
18041 for(int32_t q=0; q<11; q++)
18042 {
18043 if(!p_getc(&dummy,f,true))
18044 {
18045 return qe_invalid;
18046 }
18047 }
18048 }
18049
18050 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
18051
2/6
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 147094 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147094 if((version < 0x211)||((version == 0x211)&&(build<7)))
18052 {
18053 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
18054 {
18055 switch(temp_combo.tile)
18056 {
18057 case 130:
18058 temp_combo.tile = 132;
18059 break;
18060
18061 case 131:
18062 temp_combo.tile = 133;
18063 break;
18064
18065 case 132:
18066 temp_combo.tile = 130;
18067 break;
18068
18069 case 133:
18070 temp_combo.tile = 131;
18071 break;
18072 }
18073 }
18074 }
18075
18076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version < 25)
18077 {
18078
2/2
✓ Branch 0 taken 1157 times.
✓ Branch 1 taken 145937 times.
147094 switch(temp_combo.type)
18079 {
18080 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
18081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1157 times.
1157 if(!(temp_combo.usrflags & cflag3))
18082 1157 temp_combo.attribytes[3] = WAV_DOOR;
18083 1157 temp_combo.usrflags &= ~cflag3;
18084 1157 break;
18085 }
18086 147094 }
18087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version < 26)
18088 {
18089
2/2
✓ Branch 0 taken 146742 times.
✓ Branch 1 taken 352 times.
147094 if(temp_combo.type == cARMOS)
18090 {
18091
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 if(temp_combo.usrflags & cflag1)
18092 temp_combo.usrflags |= cflag3;
18093 352 }
18094 147094 }
18095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 if(section_version < 28)
18096 {
18097
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 146509 times.
147094 switch(temp_combo.type)
18098 {
18099 case cLOCKBLOCK: case cLOCKEDCHEST:
18100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 585 times.
585 if(temp_combo.usrflags & cflag7)
18101 temp_combo.usrflags |= cflag8;
18102 585 else temp_combo.usrflags &= ~cflag8;
18103 585 temp_combo.usrflags &= ~cflag7;
18104 585 break;
18105 }
18106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147094 times.
147094 switch(temp_combo.type)
18107 {
18108 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
18109 temp_combo.attrishorts[2] = -1;
18110 temp_combo.usrflags |= cflag7;
18111 break;
18112 }
18113 147094 }
18114
18115
2/4
✓ Branch 0 taken 147094 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 147094 times.
147094 if(keepdata==true && i>=start_combo)
18116 {
18117 147094 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
18118 147094 }
18119 147094 }
18120
18121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(keepdata==true)
18122 {
18123
2/6
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 59 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
59 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18124 {
18125 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18126 {
18127 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18128 {
18129 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18130 }
18131 }
18132 }
18133
18134 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18135
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if(version == 0x210 && !is_zquest())
18136 {
18137 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18138 if(combobuf[tmpcounter].type == cLADDERONLY)
18139 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18140 }
18141
18142
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(section_version<7)
18143 {
18144 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18145 {
18146 switch(combobuf[tmpcounter].type)
18147 {
18148 case cSLASH:
18149 combobuf[tmpcounter].type=cSLASHTOUCHY;
18150 break;
18151
18152 case cSLASHITEM:
18153 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18154 break;
18155
18156 case cBUSH:
18157 combobuf[tmpcounter].type=cBUSHTOUCHY;
18158 break;
18159
18160 case cFLOWERS:
18161 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18162 break;
18163
18164 case cTALLGRASS:
18165 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18166 break;
18167
18168 case cSLASHNEXT:
18169 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18170 break;
18171
18172 case cSLASHNEXTITEM:
18173 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18174 break;
18175
18176 case cBUSHNEXT:
18177 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18178 break;
18179 }
18180 }
18181 }
18182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if (section_version < 16)
18183 {
18184
2/2
✓ Branch 0 taken 3851520 times.
✓ Branch 1 taken 59 times.
3851579 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18185 {
18186
2/2
✓ Branch 0 taken 3848595 times.
✓ Branch 1 taken 2925 times.
3851520 if (combobuf[tmpcounter].type == cWATER)
18187 {
18188 2925 combobuf[tmpcounter].attributes[0] = 40000L;
18189 2925 }
18190 3851520 }
18191 59 }
18192
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18193 {
18194 combobuf[0].walk = 0xF0;
18195 combobuf[0].type = 0;
18196 combobuf[0].flag = 0;
18197 }
18198 59 }
18199
18200 //Now for the new combo alias reset
18201
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if(section_version<2 && keepdata)
18202 {
18203 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18204 {
18205 combo_aliases[j].width = 0;
18206 combo_aliases[j].height = 0;
18207 combo_aliases[j].layermask = 0;
18208
18209 if(combo_aliases[j].combos != NULL)
18210 {
18211 delete[] combo_aliases[j].combos;
18212 }
18213
18214 if(combo_aliases[j].csets != NULL)
18215 {
18216 delete[] combo_aliases[j].csets;
18217 }
18218
18219 combo_aliases[j].combos = new word[1];
18220 combo_aliases[j].csets = new byte[1];
18221 combo_aliases[j].combos[0] = 0;
18222 combo_aliases[j].csets[0] = 0;
18223 }
18224 }
18225
18226
18227 59 setup_combo_animations();
18228 59 setup_combo_animations2();
18229 59 return 0;
18230 59 }
18231 15372 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18232 {
18233 byte combo_has_flags;
18234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15372 times.
15372 if(!p_getc(&combo_has_flags,f,true))
18235 return qe_invalid;
18236
18237 15372 temp_combo.clear();
18238
2/2
✓ Branch 0 taken 10649 times.
✓ Branch 1 taken 4723 times.
15372 if(combo_has_flags)
18239 {
18240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4723 times.
4723 if(combo_has_flags&CHAS_GENERAL)
18241 {
18242
1/2
✓ Branch 0 taken 4723 times.
✗ Branch 1 not taken.
4723 if(!p_igetl(&temp_combo.tile,f,true))
18243 {
18244 return qe_invalid;
18245 }
18246 4723 temp_combo.o_tile = temp_combo.tile;
18247
18248
1/2
✓ Branch 0 taken 4723 times.
✗ Branch 1 not taken.
4723 if(!p_getc(&temp_combo.flip,f,true))
18249 {
18250 return qe_invalid;
18251 }
18252
18253
1/2
✓ Branch 0 taken 4723 times.
✗ Branch 1 not taken.
4723 if(!p_getc(&temp_combo.walk,f,true))
18254 {
18255 return qe_invalid;
18256 }
18257
18258
1/2
✓ Branch 0 taken 4723 times.
✗ Branch 1 not taken.
4723 if(!p_getc(&temp_combo.type,f,true))
18259 {
18260 return qe_invalid;
18261 }
18262
18263
1/2
✓ Branch 0 taken 4723 times.
✗ Branch 1 not taken.
4723 if(!p_getc(&temp_combo.flag,f,true))
18264 {
18265 return qe_invalid;
18266 }
18267
18268
1/2
✓ Branch 0 taken 4723 times.
✗ Branch 1 not taken.
4723 if(!p_getc(&temp_combo.csets,f,true))
18269 {
18270 return qe_invalid;
18271 }
18272 4723 }
18273
2/2
✓ Branch 0 taken 4722 times.
✓ Branch 1 taken 1 times.
4723 if(combo_has_flags&CHAS_SCRIPT)
18274 {
18275
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 for ( int32_t q = 0; q < 11; q++ )
18276 {
18277
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_getc(&temp_combo.label[q],f,true))
18278 {
18279 return qe_invalid;
18280 }
18281 11 }
18282
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
18283
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for ( int32_t q = 0; q < 2; q++ )
18284 {
18285
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetl(&temp_combo.initd[q],f,true))
18286 {
18287 return qe_invalid;
18288 }
18289 2 }
18290 1 }
18291
2/2
✓ Branch 0 taken 3991 times.
✓ Branch 1 taken 732 times.
4723 if(combo_has_flags&CHAS_ANIM)
18292 {
18293
1/2
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
732 if(!p_getc(&temp_combo.frames,f,true))
18294 {
18295 return qe_invalid;
18296 }
18297
18298
1/2
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
732 if(!p_getc(&temp_combo.speed,f,true))
18299 {
18300 return qe_invalid;
18301 }
18302
18303
1/2
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
732 if(!p_igetw(&temp_combo.nextcombo,f,true))
18304 {
18305 return qe_invalid;
18306 }
18307
18308
1/2
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
732 if(!p_getc(&temp_combo.nextcset,f,true))
18309 {
18310 return qe_invalid;
18311 }
18312
18313
1/2
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
732 if(!p_getc(&temp_combo.skipanim,f,true))
18314 {
18315 return qe_invalid;
18316 }
18317
18318
1/2
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
732 if(!p_getc(&temp_combo.skipanimy,f,true))
18319 {
18320 return qe_invalid;
18321 }
18322
18323
1/2
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
732 if(!p_getc(&temp_combo.animflags,f,true))
18324 {
18325 return qe_invalid;
18326 }
18327 732 }
18328
2/2
✓ Branch 0 taken 4099 times.
✓ Branch 1 taken 624 times.
4723 if(combo_has_flags&CHAS_ATTRIB)
18329 {
18330
2/2
✓ Branch 0 taken 2496 times.
✓ Branch 1 taken 624 times.
3120 for ( int32_t q = 0; q < 4; q++ )
18331 {
18332
1/2
✓ Branch 0 taken 2496 times.
✗ Branch 1 not taken.
2496 if(!p_igetl(&temp_combo.attributes[q],f,true))
18333 {
18334 return qe_invalid;
18335 }
18336 2496 }
18337
2/2
✓ Branch 0 taken 4992 times.
✓ Branch 1 taken 624 times.
5616 for ( int32_t q = 0; q < 8; q++ )
18338 {
18339
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&temp_combo.attribytes[q],f,true))
18340 {
18341 return qe_invalid;
18342 }
18343 4992 }
18344
2/2
✓ Branch 0 taken 4992 times.
✓ Branch 1 taken 624 times.
5616 for ( int32_t q = 0; q < 8; q++ )
18345 {
18346
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18347 {
18348 return qe_invalid;
18349 }
18350 4992 }
18351 624 }
18352
2/2
✓ Branch 0 taken 4529 times.
✓ Branch 1 taken 194 times.
4723 if(combo_has_flags&CHAS_FLAG)
18353 {
18354
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(!p_igetl(&temp_combo.usrflags,f,true))
18355 {
18356 return qe_invalid;
18357 }
18358
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(!p_igetw(&temp_combo.genflags,f,true))
18359 {
18360 return qe_invalid;
18361 }
18362 194 }
18363
2/2
✓ Branch 0 taken 4696 times.
✓ Branch 1 taken 27 times.
4723 if(combo_has_flags&CHAS_TRIG)
18364 {
18365
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 27 times.
108 for ( int32_t q = 0; q < 3; q++ )
18366 {
18367
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
18368 {
18369 return qe_invalid;
18370 }
18371 81 }
18372
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetl(&temp_combo.triggerlevel,f,true))
18373 {
18374 return qe_invalid;
18375 }
18376
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.triggerbtn,f,true))
18377 {
18378 return qe_invalid;
18379 }
18380
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.triggeritem,f,true))
18381 {
18382 return qe_invalid;
18383 }
18384
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.trigtimer,f,true))
18385 {
18386 return qe_invalid;
18387 }
18388
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.trigsfx,f,true))
18389 {
18390 return qe_invalid;
18391 }
18392
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetl(&temp_combo.trigchange,f,true))
18393 {
18394 return qe_invalid;
18395 }
18396
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_combo.trigprox,f,true))
18397 {
18398 return qe_invalid;
18399 }
18400
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.trigctr,f,true))
18401 {
18402 return qe_invalid;
18403 }
18404
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetl(&temp_combo.trigctramnt,f,true))
18405 {
18406 return qe_invalid;
18407 }
18408
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.triglbeam,f,true))
18409 {
18410 return qe_invalid;
18411 }
18412
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.trigcschange,f,true))
18413 {
18414 return qe_invalid;
18415 }
18416
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_combo.spawnitem,f,true))
18417 {
18418 return qe_invalid;
18419 }
18420
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_combo.spawnenemy,f,true))
18421 {
18422 return qe_invalid;
18423 }
18424
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.exstate,f,true))
18425 {
18426 return qe_invalid;
18427 }
18428
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetl(&temp_combo.spawnip,f,true))
18429 {
18430 return qe_invalid;
18431 }
18432
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.trigcopycat,f,true))
18433 {
18434 return qe_invalid;
18435 }
18436
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.trigcooldown,f,true))
18437 {
18438 return qe_invalid;
18439 }
18440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(s_version >= 35)
18441 {
18442
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_combo.prompt_cid,f,true))
18443 {
18444 return qe_invalid;
18445 }
18446
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_combo.prompt_cs,f,true))
18447 {
18448 return qe_invalid;
18449 }
18450
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_combo.prompt_x,f,true))
18451 {
18452 return qe_invalid;
18453 }
18454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(!p_igetw(&temp_combo.prompt_y,f,true))
18455 {
18456 return qe_invalid;
18457 }
18458 27 }
18459 27 }
18460
2/2
✓ Branch 0 taken 4711 times.
✓ Branch 1 taken 12 times.
4723 if(combo_has_flags&CHAS_LIFT)
18461 {
18462
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_combo.liftcmb,f,true))
18463 return qe_invalid;
18464
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftcs,f,true))
18465 return qe_invalid;
18466
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_combo.liftundercmb,f,true))
18467 return qe_invalid;
18468
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftundercs,f,true))
18469 return qe_invalid;
18470
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftdmg,f,true))
18471 return qe_invalid;
18472
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftlvl,f,true))
18473 return qe_invalid;
18474
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftitm,f,true))
18475 return qe_invalid;
18476
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftflags,f,true))
18477 return qe_invalid;
18478
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftgfx,f,true))
18479 return qe_invalid;
18480
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftsprite,f,true))
18481 return qe_invalid;
18482
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftsfx,f,true))
18483 return qe_invalid;
18484
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_combo.liftbreaksprite,f,true))
18485 return qe_invalid;
18486
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.liftbreaksfx,f,true))
18487 return qe_invalid;
18488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version >= 34)
18489 {
18490
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.lifthei,f,true))
18491 return qe_invalid;
18492
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp_combo.lifttime,f,true))
18493 return qe_invalid;
18494 12 }
18495 12 }
18496 4723 }
18497 15372 return 0;
18498 15372 }
18499 62 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos, bool keepdata)
18500 {
18501 62 word section_version=0;
18502 62 word section_cversion=0;
18503 62 word combos_used=0;
18504 int32_t dummy;
18505 byte padding;
18506 62 newcombo temp_combo;
18507
18508 62 reset_combo_animations();
18509 62 reset_combo_animations2();
18510 62 init_combo_classes();
18511
18512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata==true) //reset combos
18513 {
18514
2/2
✓ Branch 0 taken 4047360 times.
✓ Branch 1 taken 62 times.
4047422 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18515 4047360 combobuf[q].clear();
18516 62 }
18517
18518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(version > 0x192) //Version info
18519 {
18520
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&section_version,f,true))
18521 {
18522 return qe_invalid;
18523 }
18524 62 FFCore.quest_format[vCombos] = section_version;
18525
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&section_cversion,f,true))
18526 {
18527 return qe_invalid;
18528 }
18529
18530 //section size
18531
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&dummy,f,true))
18532 {
18533 return qe_invalid;
18534 }
18535 62 }
18536
18537
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(section_version > 32) //Cleanup time!
18538 {
18539
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&combos_used,f,true))
18540 {
18541 return qe_invalid;
18542 }
18543
2/2
✓ Branch 0 taken 15372 times.
✓ Branch 1 taken 3 times.
15375 for(int32_t i=0; i<combos_used; i++)
18544 {
18545 15372 auto ret = readcombo_loop(f,section_version,temp_combo);
18546
1/2
✓ Branch 0 taken 15372 times.
✗ Branch 1 not taken.
15372 if(ret) return ret;
18547
2/4
✓ Branch 0 taken 15372 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15372 times.
15372 if(keepdata==true && i>=start_combo)
18548 15372 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
18549 15372 }
18550 3 }
18551 else //Call the old function for all old versions
18552 {
18553 59 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos,keepdata);
18554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(ret) return ret; //error, end read
18555 }
18556
18557
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(keepdata && false/*section_version < 34*/)
18558 {
18559 for(int32_t i=start_combo; i<combos_used; i++)
18560 {
18561 newcombo& cmb = combobuf[i];
18562 //Do anything to 'cmb' needed for version handling
18563 }
18564 }
18565
18566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata==true)
18567 {
18568
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18569 {
18570 3 combobuf[0].walk = 0xF0;
18571 3 combobuf[0].type = 0;
18572 3 combobuf[0].flag = 0;
18573 3 }
18574 62 }
18575
18576 62 setup_combo_animations();
18577 62 setup_combo_animations2();
18578 62 return 0;
18579 62 }
18580
18581 62 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build, bool keepdata)
18582 {
18583 //these are here to bypass compiler warnings about unused arguments
18584 62 Header=Header;
18585 62 version=version;
18586 62 build=build;
18587
18588 int32_t dummy;
18589 62 word sversion=0, c_sversion;
18590
18591 //section version info
18592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(!p_igetw(&sversion,f,true))
18593 {
18594 return qe_invalid;
18595 }
18596
18597 62 FFCore.quest_format[vComboAliases] = sversion;
18598
18599 //al_trace("Combo aliases version %d\n", sversion);
18600
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&c_sversion,f,true))
18601 {
18602 return qe_invalid;
18603 }
18604
18605 //section size
18606
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&dummy,f,true))
18607 {
18608 return qe_invalid;
18609 }
18610
18611 62 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18612
18613
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18614 {
18615 59 max_num_combo_aliases = MAX250COMBOALIASES;
18616 59 }
18617
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18618 {
18619 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18620 }
18621
18622
2/2
✓ Branch 0 taken 145408 times.
✓ Branch 1 taken 62 times.
145470 for(int32_t j=0; j<max_num_combo_aliases; j++)
18623 {
18624 byte width,height,mask,tempcset;
18625 int32_t count;
18626 word tempword;
18627 byte tempbyte;
18628
18629
1/2
✓ Branch 0 taken 145408 times.
✗ Branch 1 not taken.
145408 if(!p_igetw(&tempword,f,true))
18630 {
18631 return qe_invalid;
18632 }
18633
18634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 145408 times.
145408 if(keepdata)
18635 {
18636 145408 combo_aliases[j].combo = tempword;
18637 145408 }
18638
18639
1/2
✓ Branch 0 taken 145408 times.
✗ Branch 1 not taken.
145408 if(!p_getc(&tempbyte,f,true))
18640 {
18641 return qe_invalid;
18642 }
18643
18644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 145408 times.
145408 if(keepdata)
18645 {
18646 145408 combo_aliases[j].cset = tempbyte;
18647 145408 }
18648
18649
1/2
✓ Branch 0 taken 145408 times.
✗ Branch 1 not taken.
145408 if(!p_getc(&width,f,true))
18650 {
18651 return qe_invalid;
18652 }
18653
18654
1/2
✓ Branch 0 taken 145408 times.
✗ Branch 1 not taken.
145408 if(!p_getc(&height,f,true))
18655 {
18656 return qe_invalid;
18657 }
18658
18659
1/2
✓ Branch 0 taken 145408 times.
✗ Branch 1 not taken.
145408 if(!p_getc(&mask,f,true))
18660 {
18661 return qe_invalid;
18662 }
18663
18664 145408 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18665
18666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 145408 times.
145408 if(keepdata)
18667 {
18668
1/2
✓ Branch 0 taken 145408 times.
✗ Branch 1 not taken.
145408 if(combo_aliases[j].combos != NULL)
18669 {
18670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 145408 times.
145408 delete[] combo_aliases[j].combos;
18671 145408 }
18672
18673
1/2
✓ Branch 0 taken 145408 times.
✗ Branch 1 not taken.
145408 if(combo_aliases[j].csets != NULL)
18674 {
18675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 145408 times.
145408 delete[] combo_aliases[j].csets;
18676 145408 }
18677
18678 145408 combo_aliases[j].width = width;
18679 145408 combo_aliases[j].height = height;
18680 145408 combo_aliases[j].layermask = mask;
18681 145408 combo_aliases[j].combos = new word[count];
18682 145408 combo_aliases[j].csets = new byte[count];
18683 145408 }
18684
18685
2/2
✓ Branch 0 taken 146152 times.
✓ Branch 1 taken 145408 times.
291560 for(int32_t k=0; k<count; k++)
18686 {
18687
1/2
✓ Branch 0 taken 146152 times.
✗ Branch 1 not taken.
146152 if(!p_igetw(&tempword,f,true))
18688 {
18689 return qe_invalid;
18690 }
18691
18692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146152 times.
146152 if(keepdata)
18693 {
18694 146152 combo_aliases[j].combos[k] = tempword;
18695 146152 }
18696 146152 }
18697
18698
2/2
✓ Branch 0 taken 146152 times.
✓ Branch 1 taken 145408 times.
291560 for(int32_t k=0; k<count; k++)
18699 {
18700
1/2
✓ Branch 0 taken 146152 times.
✗ Branch 1 not taken.
146152 if(!p_getc(&tempcset,f,true))
18701 {
18702 return qe_invalid;
18703 }
18704
18705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146152 times.
146152 if(keepdata)
18706 {
18707 146152 combo_aliases[j].csets[k] = tempcset;
18708 146152 }
18709 146152 }
18710 145408 }
18711
18712 62 word num_combo_pools = 0;
18713
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if(sversion >= 4)
18714 {
18715
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&num_combo_pools,f,true))
18716 {
18717 return qe_invalid;
18718 }
18719 3 }
18720
18721
2/2
✓ Branch 0 taken 507904 times.
✓ Branch 1 taken 62 times.
507966 for(combo_pool& pool : combo_pools)
18722 {
18723 507904 pool.clear();
18724 }
18725
18726 62 combo_pool temp_cpool;
18727
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 62 times.
71 for(word cp = 0; cp < num_combo_pools; ++cp)
18728 {
18729 9 int32_t num_combos_in_pool = 0;
18730
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 if(!p_igetl(&num_combos_in_pool,f,true))
18731 {
18732 return qe_invalid;
18733 }
18734
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(num_combos_in_pool < 1) continue; //nothing to read
18735
18736
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 temp_cpool.clear();
18737
18738 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18739
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 9 times.
48 for(auto q = 0; q < num_combos_in_pool; ++q)
18740 {
18741
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 if(!p_igetl(&cp_cid,f,true))
18742 {
18743 return qe_invalid;
18744 }
18745
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 if(!p_getc(&cp_cs,f,true))
18746 {
18747 return qe_invalid;
18748 }
18749
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 if(!p_igetw(&cp_quant,f,true))
18750 {
18751 return qe_invalid;
18752 }
18753
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18754 39 }
18755
18756
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(keepdata)
18757 {
18758
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 combo_pools[cp] = temp_cpool;
18759 9 }
18760 9 }
18761
18762 62 return 0;
18763 62 }
18764
18765 62 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets, bool keepdata)
18766 {
18767 //these are here to bypass compiler warnings about unused arguments
18768
18769 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18770 //Capitalized cause it'll save you a headache. -Deedee
18771 62 start_cset=start_cset;
18772 62 max_csets=max_csets;
18773 62 word s_version=0;
18774
18775 miscQdata temp_misc;
18776 62 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18777
18778 byte temp_colordata[48];
18779 char temp_palname[PALNAMESIZE];
18780
18781 int32_t dummy;
18782 word palcycles;
18783
18784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(version > 0x192)
18785 {
18786 //section version info
18787
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_version,f,true))
18788 {
18789 return qe_invalid;
18790 }
18791
18792 62 FFCore.quest_format[vCSets] = s_version;
18793
18794 //al_trace("Color data version %d\n", s_version);
18795
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&dummy,f,true))
18796 {
18797 return qe_invalid;
18798 }
18799
18800 //section size
18801
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&dummy,f,true))
18802 {
18803 return qe_invalid;
18804 }
18805 62 }
18806
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if (s_version < 5)
18807 {
18808
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18809
18810 //finally... section data
18811 59 int32_t q = 0;
18812 59 int32_t p = -15;
18813
2/2
✓ Branch 0 taken 14160 times.
✓ Branch 1 taken 59 times.
14219 for(int32_t i=0; i<oldpdTOTAL; ++i)
18814 {
18815 14160 memset(temp_colordata, 0, 48);
18816
18817
1/2
✓ Branch 0 taken 14160 times.
✗ Branch 1 not taken.
14160 if(!pfread(temp_colordata,48,f,true))
18818 {
18819 return qe_invalid;
18820 }
18821
18822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14160 times.
14160 if(keepdata==true)
18823 {
18824 14160 memcpy(&colordata[q*48], temp_colordata, 48);
18825 14160 }
18826 14160 ++q;
18827
7/8
✓ Branch 0 taken 13216 times.
✓ Branch 1 taken 944 times.
✓ Branch 2 taken 1003 times.
✓ Branch 3 taken 12213 times.
✓ Branch 4 taken 118 times.
✓ Branch 5 taken 885 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 118 times.
14160 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18828 {
18829
1/2
✓ Branch 0 taken 1003 times.
✗ Branch 1 not taken.
1003 if (s_version < 5) //Bumping up the size of level palettes
18830 {
18831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1003 times.
1003 if(keepdata==true)
18832 {
18833 1003 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18834 1003 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18835 1003 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18836 1003 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18837 1003 }
18838 1003 q+=4;
18839 1003 }
18840 else
18841 {
18842 for(int m = 0; m < 4; ++m)
18843 {
18844 memset(temp_colordata, 0, 48);
18845 if(!pfread(temp_colordata,48,f,true))
18846 {
18847 return qe_invalid;
18848 }
18849 if(keepdata==true)
18850 {
18851 memcpy(&colordata[q*48], temp_colordata, 48);
18852 }
18853 ++q;
18854 }
18855 }
18856 1003 }
18857 14160 ++p;
18858 14160 }
18859
18860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(RealOldVerion)
18861 {
18862 if(keepdata==true)
18863 {
18864 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18865 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18866 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18867 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18868 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18869 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18870 }
18871 }
18872 else
18873 {
18874 59 memset(temp_colordata, 0, 48);
18875
18876
2/2
✓ Branch 0 taken 184847 times.
✓ Branch 1 taken 59 times.
184906 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18877 {
18878
1/2
✓ Branch 0 taken 184847 times.
✗ Branch 1 not taken.
184847 if(!pfread(temp_colordata,48,f,true))
18879 {
18880 return qe_invalid;
18881 }
18882
18883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 184847 times.
184847 if(keepdata==true)
18884 {
18885 184847 memcpy(&colordata[q*48], temp_colordata, 48);
18886 184847 }
18887 184847 ++q;
18888
6/8
✓ Branch 0 taken 184847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14219 times.
✓ Branch 3 taken 170628 times.
✓ Branch 4 taken 118 times.
✓ Branch 5 taken 14101 times.
✓ Branch 6 taken 118 times.
✗ Branch 7 not taken.
184847 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18889 {
18890
1/2
✓ Branch 0 taken 14219 times.
✗ Branch 1 not taken.
14219 if (s_version < 5) //Bumping up the size of level palettes
18891 {
18892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14219 times.
14219 if(keepdata==true)
18893 {
18894 14219 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18895 14219 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18896 14219 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18897 14219 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18898 14219 }
18899 14219 q+=4;
18900 14219 }
18901 else
18902 {
18903 for(int m = 0; m < 4; ++m)
18904 {
18905 memset(temp_colordata, 0, 48);
18906 if(!pfread(temp_colordata,48,f,true))
18907 {
18908 return qe_invalid;
18909 }
18910 if(keepdata==true)
18911 {
18912 memcpy(&colordata[q*48], temp_colordata, 48);
18913 }
18914 ++q;
18915 }
18916 }
18917 14219 }
18918 184847 ++p;
18919 184847 }
18920
18921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if(s_version < 4)
18922 {
18923 if(keepdata==true)
18924 {
18925 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18926 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18927 }
18928 }
18929 else
18930 {
18931
2/2
✓ Branch 0 taken 196352 times.
✓ Branch 1 taken 59 times.
196411 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18932 {
18933
1/2
✓ Branch 0 taken 196352 times.
✗ Branch 1 not taken.
196352 if(!pfread(temp_colordata,48,f,true))
18934 {
18935 return qe_invalid;
18936 }
18937
18938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196352 times.
196352 if(keepdata==true)
18939 {
18940 196352 memcpy(&colordata[q*48], temp_colordata, 48);
18941 196352 }
18942 196352 ++q;
18943
5/6
✓ Branch 0 taken 196352 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15104 times.
✓ Branch 3 taken 181248 times.
✓ Branch 4 taken 118 times.
✓ Branch 5 taken 14986 times.
196352 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18944 {
18945
1/2
✓ Branch 0 taken 14986 times.
✗ Branch 1 not taken.
14986 if (s_version < 5) //Bumping up the size of level palettes
18946 {
18947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14986 times.
14986 if(keepdata==true)
18948 {
18949 14986 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18950 14986 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18951 14986 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18952 14986 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18953 14986 }
18954 14986 q+=4;
18955 14986 }
18956 else
18957 {
18958 for(int m = 0; m < 4; ++m)
18959 {
18960 memset(temp_colordata, 0, 48);
18961 if(!pfread(temp_colordata,48,f,true))
18962 {
18963 return qe_invalid;
18964 }
18965 if(keepdata==true)
18966 {
18967 memcpy(&colordata[q*48], temp_colordata, 48);
18968 }
18969 ++q;
18970 }
18971 }
18972 14986 }
18973 196352 ++p;
18974 196352 }
18975
18976 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18977 }
18978 }
18979 59 }
18980 else
18981 {
18982
2/2
✓ Branch 0 taken 26247 times.
✓ Branch 1 taken 3 times.
26250 for(int32_t i=0; i<pdTOTAL255; ++i)
18983 {
18984 26247 memset(temp_colordata, 0, 48);
18985
18986
1/2
✓ Branch 0 taken 26247 times.
✗ Branch 1 not taken.
26247 if(!pfread(temp_colordata,48,f,true))
18987 {
18988 return qe_invalid;
18989 }
18990
18991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26247 times.
26247 if(keepdata==true)
18992 {
18993 26247 memcpy(&colordata[i*48], temp_colordata, 48);
18994 26247 }
18995 26247 }
18996 }
18997
18998
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if((version < 0x192)||((version == 0x192)&&(build<76)))
18999 {
19000 if(keepdata==true)
19001 {
19002 init_palnames();
19003 }
19004 }
19005 else
19006 {
19007 62 int32_t palnamestoread = 0;
19008
19009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(s_version < 3)
19010 palnamestoread = OLDMAXLEVELS;
19011 else
19012 62 palnamestoread = 512;
19013
19014
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 62 times.
31806 for(int32_t i=0; i<palnamestoread; ++i)
19015 {
19016 31744 memset(temp_palname, 0, PALNAMESIZE);
19017
19018
1/2
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
31744 if(!pfread(temp_palname,PALNAMESIZE,f,true))
19019 {
19020 return qe_invalid;
19021 }
19022
19023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31744 times.
31744 if(keepdata==true)
19024 {
19025 31744 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19026 31744 }
19027 31744 }
19028
19029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata)
19030 {
19031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19032 {
19033 memset(palnames[i], 0, PALNAMESIZE);
19034 }
19035 62 }
19036 }
19037
19038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(version > 0x192)
19039 {
19040
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<256; i++)
19041 {
19042
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 15872 times.
63488 for(int32_t j=0; j<3; j++)
19043 {
19044 47616 temp_misc.cycles[i][j].first=0;
19045 47616 temp_misc.cycles[i][j].count=0;
19046 47616 temp_misc.cycles[i][j].speed=0;
19047 47616 }
19048 15872 }
19049
19050
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&palcycles,f,true))
19051 {
19052 return qe_invalid;
19053 }
19054
19055
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 62 times.
2420 for(int32_t i=0; i<palcycles; i++)
19056 {
19057
2/2
✓ Branch 0 taken 7074 times.
✓ Branch 1 taken 2358 times.
9432 for(int32_t j=0; j<3; j++)
19058 {
19059
1/2
✓ Branch 0 taken 7074 times.
✗ Branch 1 not taken.
7074 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
19060 {
19061 return qe_invalid;
19062 }
19063 7074 }
19064
19065
2/2
✓ Branch 0 taken 7074 times.
✓ Branch 1 taken 2358 times.
9432 for(int32_t j=0; j<3; j++)
19066 {
19067
1/2
✓ Branch 0 taken 7074 times.
✗ Branch 1 not taken.
7074 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
19068 {
19069 return qe_invalid;
19070 }
19071 7074 }
19072
19073
2/2
✓ Branch 0 taken 7074 times.
✓ Branch 1 taken 2358 times.
9432 for(int32_t j=0; j<3; j++)
19074 {
19075
1/2
✓ Branch 0 taken 7074 times.
✗ Branch 1 not taken.
7074 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
19076 {
19077 return qe_invalid;
19078 }
19079 7074 }
19080 2358 }
19081
19082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata==true)
19083 {
19084 62 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19085 62 }
19086 62 }
19087
19088 62 return 0;
19089 62 }
19090
19091 62 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init, bool keepdata)
19092 {
19093 62 int32_t tiles_used=0;
19094 62 word section_version = 0;
19095 62 word section_cversion = 0;
19096 62 int32_t section_size= 0;
19097 62 byte *temp_tile = new byte[tilesize(tf32Bit)];
19098
19099 //Tile Expansion
19100 //if ( version >= 0x254 && build >= 41 )
19101
3/4
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 59 times.
62 if (version < 0x254 && build < 41)
19102 {
19103 //al_trace("Build was < 41 when reading tiles\n");
19104 59 max_tiles = ZC250MAXTILES;
19105 59 }
19106
19107 //al_trace("Max Tiles: %d\n", max_tiles);
19108
19109
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19110 {
19111 if(keepdata==true)
19112 {
19113 if(!init_tiles(true, Header))
19114 {
19115 al_trace("Unable to initialize tiles\n");
19116 }
19117 }
19118
19119 delete[] temp_tile;
19120 temp_tile=NULL;
19121 return 0;
19122 }
19123 else
19124 {
19125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(version > 0x192)
19126 {
19127 //section version info
19128
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&section_version,f,true))
19129 {
19130 delete[] temp_tile;
19131 return qe_invalid;
19132 }
19133
19134 62 FFCore.quest_format[vTiles] = section_version;
19135
19136
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&section_cversion,f,true))
19137 {
19138 delete[] temp_tile;
19139 return qe_invalid;
19140 }
19141
19142 //section size
19143
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&section_size,f,true))
19144 {
19145 delete[] temp_tile;
19146 return qe_invalid;
19147 }
19148 62 }
19149
19150 //if ( build < 41 )
19151 //{
19152 // tiles_used = ZC250MAXTILES;
19153 //}
19154
19155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(version < 0x174)
19156 {
19157 tiles_used=TILES_PER_PAGE*4;
19158 } //no expanded tile space
19159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 else if(version < 0x191)
19160 {
19161 tiles_used=OLDMAXTILES;
19162 }
19163 else
19164 {
19165 //finally... section data
19166
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
62 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19167 {
19168
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetl(&tiles_used,f,true))
19169 {
19170 delete[] temp_tile;
19171 return qe_invalid;
19172 }
19173 3 }
19174 else
19175 {
19176
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&tiles_used,f,true))
19177 {
19178 delete[] temp_tile;
19179 return qe_invalid;
19180 }
19181 }
19182 }
19183
19184
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 tiles_used=zc_min(tiles_used, max_tiles);
19185
19186 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19187 //if ( version < 0x254 && build < 41 )
19188
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if ( version < 0x254 || (version == 0x254 && build < 41) )
19189 //if ( build < 41 )
19190 {
19191
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19192 59 }
19193 else //2.55
19194 {
19195
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19196 }
19197
19198 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19199
19200 //al_trace("tiles_used = %d\n", tiles_used);
19201
19202
2/2
✓ Branch 0 taken 880746 times.
✓ Branch 1 taken 62 times.
880808 for(int32_t i=0; i<tiles_used; ++i)
19203 {
19204 880746 byte format=tf4Bit;
19205 880746 memset(temp_tile, 0, tilesize(tf32Bit));
19206
19207
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 880746 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
880746 if((version>0x211)||((version==0x211)&&(build>4)))
19208 {
19209
1/2
✓ Branch 0 taken 880746 times.
✗ Branch 1 not taken.
880746 if(!p_getc(&format,f,true))
19210 {
19211 delete[] temp_tile;
19212 return qe_invalid;
19213 }
19214 880746 }
19215
4/4
✓ Branch 0 taken 70156 times.
✓ Branch 1 taken 810590 times.
✓ Branch 2 taken 34845 times.
✓ Branch 3 taken 35311 times.
880746 if(section_version > 2 && !format)
19216 {
19217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35311 times.
35311 if(keepdata)
19218 {
19219 35311 reset_tile(buf,start_tile+i,tf4Bit);
19220 35311 }
19221 35311 continue;
19222 }
19223
19224
1/2
✓ Branch 0 taken 845435 times.
✗ Branch 1 not taken.
845435 if(!pfread(temp_tile,tilesize(format),f,true))
19225 {
19226 delete[] temp_tile;
19227 return qe_invalid;
19228 }
19229
19230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 845435 times.
845435 if(keepdata==true)
19231 {
19232 845435 buf[start_tile+i].format=format;
19233
19234
1/2
✓ Branch 0 taken 845435 times.
✗ Branch 1 not taken.
845435 if(buf[start_tile+i].data)
19235 {
19236 845435 free(buf[start_tile+i].data);
19237 845435 buf[start_tile+i].data=NULL;
19238 845435 }
19239
19240 845435 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19241 845435 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19242 845435 }
19243 845435 }
19244 }
19245
19246
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19247 {
19248 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19249
2/2
✓ Branch 0 taken 8789820 times.
✓ Branch 1 taken 59 times.
8789879 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19250 {
19251
19252 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19253 8789820 reset_tile(buf,q,tf4Bit);
19254
19255
19256 /*
19257
19258 byte tempbyte;
19259 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19260 {
19261 tempbyte=buf[ZC250MAXTILES-1].data[i];
19262 buf[q].data[i] = tempbyte;
19263 }
19264 //int32_t temp = tempbyte=buf[130].data[i];
19265 //buf[q].data = buf[ZC250MAXTILES-1].data;
19266 */
19267 //reset_tile(buf,q,tf4Bit);
19268 8789820 }
19269
19270 59 }
19271
19272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata==true)
19273 {
19274
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
62 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19275 {
19276
2/2
✓ Branch 0 taken 3090168 times.
✓ Branch 1 taken 59 times.
3090227 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19277 {
19278 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19279 3090168 reset_tile(buf,i,tf4Bit);
19280 3090168 }
19281 59 }
19282 else
19283 {
19284
2/2
✓ Branch 0 taken 538266 times.
✓ Branch 1 taken 3 times.
538269 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19285 {
19286 //al_trace("Resetting tiles for build 41+\n");
19287 538266 reset_tile(buf,i,tf4Bit);
19288 538266 }
19289 }
19290
19291
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19292 {
19293 if(get_bit(quest_rules,qr_BSZELDA)) //
19294 {
19295 byte tempbyte;
19296 int32_t floattile=wpnsbuf[iwSwim].tile;
19297
19298 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19299 {
19300 tempbyte=buf[23].data[i];
19301 buf[23].data[i]=buf[24].data[i];
19302 buf[24].data[i]=buf[25].data[i];
19303 buf[25].data[i]=buf[26].data[i];
19304 buf[26].data[i]=tempbyte;
19305 }
19306 //swim tiles are out of order, too, but nobody cared? -Z
19307 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19308 {
19309 tempbyte=buf[floattile+11].data[i];
19310 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19311 buf[floattile+12].data[i]=tempbyte;
19312 }
19313 }
19314 }
19315
19316
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19317 {
19318 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
19319 {
19320 byte tempbyte;
19321
19322 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19323 {
19324 tempbyte=buf[130].data[i];
19325 buf[130].data[i]=buf[132].data[i];
19326 buf[132].data[i]=tempbyte;
19327
19328 tempbyte=buf[131].data[i];
19329 buf[131].data[i]=buf[133].data[i];
19330 buf[133].data[i]=tempbyte;
19331 }
19332 }
19333 }
19334
19335 62 al_trace("Registering blank tiles\n");
19336 62 register_blank_tiles();
19337 62 }
19338
19339 //memset(temp_tile, 0, tilesize(tf32Bit));
19340
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 delete[] temp_tile;
19341 62 temp_tile=NULL;
19342 62 return 0;
19343 62 }
19344
19345 62 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/, bool keepdata)
19346 {
19347 62 byte *mf=midi_flags;
19348 int32_t dummy;
19349 word dummy2;
19350 // zcmidi_ temp_midi;
19351 int32_t tunes_to_read;
19352 62 int32_t tune_count=0;
19353 62 word section_version=0;
19354 62 zctune temp;
19355
19356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(Header->zelda_version < 0x193)
19357 {
19358 // mf=Header->data_flags+ZQ_MIDIS2;
19359 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19360 {
19361 tunes_to_read=MAXCUSTOMMIDIS192b177;
19362 }
19363 else
19364 {
19365 tunes_to_read=MAXCUSTOMTUNES;
19366 }
19367 }
19368 else
19369 {
19370 //section version info
19371
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&section_version,f,true))
19372 {
19373 return qe_invalid;
19374 }
19375
19376 62 FFCore.quest_format[vMIDIs] = section_version;
19377
19378 //al_trace("Tunes version %d\n", section_version);
19379
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&dummy2,f,true))
19380 {
19381 return qe_invalid;
19382 }
19383
19384 //section size
19385
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&dummy,f,true))
19386 {
19387 return qe_invalid;
19388 }
19389
19390 //finally... section data
19391
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!pfread(midi_flags,sizeof(midi_flags),f,true))
19392 {
19393 return qe_invalid;
19394 }
19395
19396 62 tunes_to_read=MAXCUSTOMTUNES;
19397 }
19398
19399
2/2
✓ Branch 0 taken 15624 times.
✓ Branch 1 taken 62 times.
15686 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19400 {
19401
2/2
✓ Branch 0 taken 14443 times.
✓ Branch 1 taken 1181 times.
15624 if(get_bit(mf, i))
19402 {
19403 1181 ++tune_count;
19404 1181 }
19405 15624 }
19406
19407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata==true)
19408 {
19409 62 reset_tunes(tunes); //reset_midis(midis);
19410 62 }
19411
19412
2/2
✓ Branch 0 taken 15624 times.
✓ Branch 1 taken 62 times.
15686 for(int32_t i=0; i<tunes_to_read; i++)
19413 {
19414 15624 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19415
19416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15624 times.
15624 if(keepdata==true)
19417 {
19418 15624 tunes[i].reset(); // reset_midi(midis+i);
19419 15624 }
19420
19421
2/2
✓ Branch 0 taken 14443 times.
✓ Branch 1 taken 1181 times.
15624 if(get_bit(mf,i))
19422 {
19423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1181 times.
1181 if(section_version < 4)
19424 {
19425 if(!pfread(&temp.title,sizeof(char)*20,f,true))
19426 {
19427 return qe_invalid;
19428 }
19429 }
19430 else
19431 {
19432
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(!pfread(&temp.title,sizeof(temp.title),f,true))
19433 {
19434 return qe_invalid;
19435 }
19436 }
19437
19438
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(!p_igetl(&temp.start,f,true))
19439 {
19440 return qe_invalid;
19441 }
19442
19443
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(!p_igetl(&temp.loop_start,f,true))
19444 {
19445 return qe_invalid;
19446 }
19447
19448
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(!p_igetl(&temp.loop_end,f,true))
19449 {
19450 return qe_invalid;
19451 }
19452
19453
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(!p_igetw(&temp.loop,f,true))
19454 {
19455 return qe_invalid;
19456 }
19457
19458
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(!p_igetw(&temp.volume,f,true))
19459 {
19460 return qe_invalid;
19461 }
19462
19463
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(Header->zelda_version < 0x193)
19464 {
19465 if(!p_igetl(&dummy,f,true))
19466 {
19467 return qe_invalid;
19468 }
19469 }
19470
19471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1181 times.
1181 if(section_version >= 3)
19472 {
19473
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 if(!pfread(&temp.flags,sizeof(temp.flags),f,true))
19474 {
19475 return qe_invalid;
19476 }
19477 1181 }
19478
19479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1181 times.
1181 if(keepdata==true)
19480 {
19481 1181 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19482 1181 }
19483
19484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1181 times.
1181 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19485 {
19486 // old format - a midi is a midi
19487 if(((keepdata==true?tunes[i].data:temp.data)=read_midi(f, true))==NULL)
19488 {
19489 return qe_invalid;
19490 }
19491
19492 //yes you can do this. Isn't the ? operator awesome? :)
19493 (keepdata ? tunes[i] : temp).format = MFORMAT_MIDI;
19494 }
19495 else
19496 {
19497 // 'midi' could be midi or nes, gb, ... music
19498
2/4
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1181 times.
✗ Branch 3 not taken.
1181 if(!pfread(&(keepdata ? tunes[i] : temp).format,sizeof((keepdata ? tunes[i] : temp).format),f,true))
19499 {
19500 return qe_invalid;
19501 }
19502
19503
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 zctune *ptr = (keepdata==true)?&(tunes[i]):&temp;
19504
19505
1/2
✓ Branch 0 taken 1181 times.
✗ Branch 1 not taken.
1181 switch(temp.format)
19506 {
19507 case MFORMAT_MIDI:
19508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1181 times.
1181 if((ptr->data=read_midi(f, true))==NULL)
19509 {
19510 return qe_invalid;
19511 }
19512
19513 1181 break;
19514
19515 default:
19516 return qe_invalid;
19517 break;
19518 }
19519 }
19520 1181 }
19521 15624 }
19522
19523 62 return 0;
19524 62 }
19525
19526 62 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header, bool keepdata)
19527 {
19528 int32_t dummy;
19529 ZCHEATS tempzcheats;
19530 62 char temp_use_cheats=1;
19531 62 memset(&tempzcheats, 0, sizeof(tempzcheats));
19532 62 word s_version = 0;
19533
19534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(Header->zelda_version > 0x192)
19535 {
19536 //section version info
19537
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_version,f,true))
19538 {
19539 return qe_invalid;
19540 }
19541
19542 62 FFCore.quest_format[vCheats] = s_version;
19543 //al_trace("Cheats version %d\n", dummy);
19544
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&dummy,f,true))
19545 {
19546 return qe_invalid;
19547 }
19548
19549 //section size
19550
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&dummy,f,true))
19551 {
19552 return qe_invalid;
19553 }
19554
19555 //finally... section data
19556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(!p_getc(&temp_use_cheats,f,true))
19557 {
19558 return qe_invalid;
19559 }
19560 62 }
19561
19562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(Header->data_flags[ZQ_CHEATS2])
19563 {
19564
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&tempzcheats.flags,f,true))
19565 {
19566 return qe_invalid;
19567 }
19568
19569
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes), f,true))
19570 {
19571 return qe_invalid;
19572 }
19573 62 }
19574
19575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata==true)
19576 {
19577 62 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19578 62 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19579 62 }
19580
19581 62 return 0;
19582 62 }
19583
19584 180 int32_t readinitdata(PACKFILE *f, zquestheader *Header, bool keepdata)
19585 {
19586 int32_t dummy;
19587 180 word s_version=0, s_cversion=0;
19588 byte padding;
19589 word tempw;
19590
19591 180 zinitdata temp_zinit;
19592
19593 // Legacy item properties (now integrated into itemdata)
19594 byte sword_hearts[4];
19595 byte beam_hearts[4];
19596 180 byte beam_percent=0;
19597 word beam_power[4];
19598 180 byte hookshot_length=99;
19599 180 byte hookshot_links=100;
19600 180 byte longshot_length=99;
19601 180 byte longshot_links=100;
19602 180 byte moving_fairy_hearts=3;
19603 180 byte moving_fairy_heart_percent=0;
19604 180 byte stationary_fairy_hearts=3;
19605 180 byte stationary_fairy_heart_percent=0;
19606 180 byte moving_fairy_magic=0;
19607 180 byte moving_fairy_magic_percent=0;
19608 180 byte stationary_fairy_magic=0;
19609 180 byte stationary_fairy_magic_percent=0;
19610 180 byte blue_potion_hearts=100;
19611 180 byte blue_potion_heart_percent=1;
19612 180 byte red_potion_hearts=100;
19613 180 byte red_potion_heart_percent=1;
19614 180 byte blue_potion_magic=100;
19615 180 byte blue_potion_magic_percent=1;
19616 180 byte red_potion_magic=100;
19617 180 byte red_potion_magic_percent=1;
19618
19619
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 118 times.
180 temp_zinit.subscreen_style=get_bit(quest_rules,qr_COOLSCROLL)?1:0;
19620
19621
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(Header->zelda_version > 0x192)
19622 {
19623 //section version info
19624
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&s_version,f,true))
19625 {
19626 return qe_invalid;
19627 }
19628
19629 62 FFCore.quest_format[vInitData] = s_version;
19630
19631 //al_trace("Init data version %d\n", s_version);
19632
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&s_cversion,f,true))
19633 {
19634 return qe_invalid;
19635 }
19636
19637 //section size
19638
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetl(&dummy,f,true))
19639 {
19640 return qe_invalid;
19641 }
19642 62 }
19643
19644 /* HIGHLY UNORTHODOX UPDATING THING, by L
19645 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19646 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19647 * changing from 13 to 14.
19648 */
19649
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(keepdata && s_version < 14)
19650 fixpolsvoice=true;
19651
19652 /* End highly unorthodox updating thing */
19653
19654
4/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
✓ Branch 5 taken 3 times.
62 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19655 3 temp_zinit.jump_hero_layer_threshold=0;
19656
19657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(s_version >= 10)
19658 {
19659 char temp;
19660
19661 //new-style items
19662
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t j=0; j<256; j++)
19663 {
19664
2/4
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15872 times.
15872 if(!p_getc(&temp,f,true))
19665 return qe_invalid;
19666
19667 15872 temp_zinit.items[j] = (temp != 0);
19668 15872 }
19669 62 }
19670
19671
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 56 times.
62 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19672 {
19673 char temp;
19674
19675 //finally... section data
19676
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 56 times.
118 if((Header->zelda_version > 0x192)||
19677 //new only
19678 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19679 {
19680 //OLD-style items... sigh
19681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(s_version < 10)
19682 {
19683 if(!p_getc(&temp,f,true))
19684 {
19685 return qe_invalid;
19686 }
19687
19688 temp_zinit.items[iRaft]=(temp != 0);
19689
19690 if(!p_getc(&temp,f,true))
19691 {
19692 return qe_invalid;
19693 }
19694
19695 temp_zinit.items[iLadder]=(temp != 0);
19696
19697 if(!p_getc(&temp,f,true))
19698 {
19699 return qe_invalid;
19700 }
19701
19702 temp_zinit.items[iBook]=(temp != 0);
19703
19704 if(!p_getc(&temp,f,true))
19705 {
19706 return qe_invalid;
19707 }
19708
19709 temp_zinit.items[iMKey]=(temp!=0);
19710
19711 if(!p_getc(&temp,f,true))
19712 {
19713 return qe_invalid;
19714 }
19715
19716 temp_zinit.items[iFlippers]=(temp != 0);
19717
19718 if(!p_getc(&temp,f,true))
19719 {
19720 return qe_invalid;
19721 }
19722
19723 temp_zinit.items[iBoots]=(temp!=0);
19724 }
19725 62 }
19726
19727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if(s_version < 10)
19728 {
19729 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19730
19731 if(!p_getc(&tempring,f,true))
19732 {
19733 return qe_invalid;
19734 }
19735
19736 if(!p_getc(&tempsword,f,true))
19737 {
19738 return qe_invalid;
19739 }
19740
19741 if(!p_getc(&tempshield,f,true))
19742 {
19743 return qe_invalid;
19744 }
19745
19746 if(!p_getc(&tempwallet,f,true))
19747 {
19748 return qe_invalid;
19749 }
19750
19751 if(!p_getc(&tempbracelet,f,true))
19752 {
19753 return qe_invalid;
19754 }
19755
19756 if(!p_getc(&tempamulet,f,true))
19757 {
19758 return qe_invalid;
19759 }
19760
19761 if(!p_getc(&tempbow,f,true))
19762 {
19763 return qe_invalid;
19764 }
19765
19766 //old only
19767 if((Header->zelda_version == 0x192)&&(Header->build<174))
19768 {
19769 tempring=(tempring)?(1<<(tempring-1)):0;
19770 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19771 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19772 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19773 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19774 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19775 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19776 }
19777
19778 //rings start at level 2... wtf
19779 //account for this -DD
19780 tempring <<= 1;
19781 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19782 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19783 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19784 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19785 //bracelet ALSO starts at level 2 :-( -DD
19786 tempbracelet<<=1;
19787 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19788 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19789 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19790
19791 //new only
19792 if((Header->zelda_version == 0x192)&&(Header->build>173))
19793 {
19794 for(int32_t q=0; q<32; q++)
19795 {
19796 if(!p_getc(&padding,f,true))
19797 {
19798 return qe_invalid;
19799 }
19800 }
19801 }
19802
19803 char tempcandle, tempboomerang, temparrow, tempwhistle;
19804
19805 if(!p_getc(&tempcandle,f,true))
19806 {
19807 return qe_invalid;
19808 }
19809
19810 if(!p_getc(&tempboomerang,f,true))
19811 {
19812 return qe_invalid;
19813 }
19814
19815 if(!p_getc(&temparrow,f,true))
19816 {
19817 return qe_invalid;
19818 }
19819
19820 if(!p_getc(&temp,f,true))
19821 {
19822 return qe_invalid;
19823 }
19824
19825 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19826
19827 if(!p_getc(&tempwhistle,f,true))
19828 {
19829 return qe_invalid;
19830 }
19831
19832 //old only
19833 if((Header->zelda_version == 0x192)&&(Header->build<174))
19834 {
19835 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19836 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19837 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19838 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19839 }
19840
19841 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19842 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19843 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19844 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19845 //What about the potion...?
19846
19847 }
19848
19849
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 59 times.
118 if(s_version < 29)
19850 {
19851 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19852 //to jab out my eye...
19853
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_getc(&padding,f,true))
19854 return qe_invalid;
19855 59 temp_zinit.bombs = padding;
19856
19857
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_getc(&padding,f,true))
19858 return qe_invalid;
19859 59 temp_zinit.super_bombs = padding;
19860 59 }
19861
19862 //Back to more OLD item code
19863
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
118 if(s_version < 10)
19864 {
19865 if((Header->zelda_version > 0x192)||
19866 //new only
19867 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19868 {
19869 if(!p_getc(&temp,f,true))
19870 {
19871 return qe_invalid;
19872 }
19873
19874 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19875
19876 if(!p_getc(&temp,f,true))
19877 {
19878 return qe_invalid;
19879 }
19880
19881 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19882
19883 if(!p_getc(&temp,f,true))
19884 {
19885 return qe_invalid;
19886 }
19887
19888 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19889
19890 if(!p_getc(&temp,f,true))
19891 {
19892 return qe_invalid;
19893 }
19894
19895 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19896
19897 if(!p_getc(&temp,f,true))
19898 {
19899 return qe_invalid;
19900 }
19901
19902 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19903
19904 if(!p_getc(&temp,f,true))
19905 {
19906 return qe_invalid;
19907 }
19908
19909 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19910
19911 if(!p_getc(&temp,f,true))
19912 {
19913 return qe_invalid;
19914 }
19915
19916 addOldStyleFamily(&temp_zinit, itemsbuf, itype_dinsfire, temp);
19917
19918 if(!p_getc(&temp,f,true))
19919 {
19920 return qe_invalid;
19921 }
19922
19923 addOldStyleFamily(&temp_zinit, itemsbuf, itype_faroreswind, temp);
19924
19925 if(!p_getc(&temp,f,true))
19926 {
19927 return qe_invalid;
19928 }
19929
19930 addOldStyleFamily(&temp_zinit, itemsbuf, itype_nayruslove, temp);
19931
19932 if(!p_getc(&temp,f,true))
19933 {
19934 return qe_invalid;
19935 }
19936
19937 if(Header->zelda_version == 0x192)
19938 {
19939 for(int32_t q=0; q<32; q++)
19940 {
19941 if(!p_getc(&padding,f,true))
19942 {
19943 return qe_invalid;
19944 }
19945 }
19946 }
19947 }
19948 }
19949
19950 //old only
19951 if((Header->zelda_version == 0x192)&&(Header->build<174))
19952 {
19953 byte equipment, items; //bit flags
19954
19955 if(!p_getc(&equipment,f,true))
19956 {
19957 return qe_invalid;
19958 }
19959
19960 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19961 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19962 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19963 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19964 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19965 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19966
19967
19968 if(!p_getc(&items,f,true))
19969 {
19970 return qe_invalid;
19971 }
19972
19973 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
19974 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
19975 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
19976 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
19977 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
19978 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
19979 }
19980
19981 if(!p_getc(&temp_zinit.hc,f,true))
19982 {
19983 return qe_invalid;
19984 }
19985
19986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(s_version < 14)
19987 {
19988 byte temphp;
19989
19990 if(!p_getc(&temphp,f,true))
19991 {
19992 return qe_invalid;
19993 }
19994
19995 temp_zinit.start_heart=temphp;
19996
19997 if(!p_getc(&temphp,f,true))
19998 {
19999 return qe_invalid;
20000 }
20001
20002 temp_zinit.cont_heart=temphp;
20003 }
20004 else
20005 {
20006
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_zinit.start_heart,f,true))
20007 {
20008 return qe_invalid;
20009 }
20010
20011
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_zinit.cont_heart,f,true))
20012 {
20013 return qe_invalid;
20014 }
20015 }
20016
20017
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.hcp,f,true))
20018 {
20019 return qe_invalid;
20020 }
20021
20022
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version >= 14)
20023 {
20024
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.hcp_per_hc,f,true))
20025 {
20026 return qe_invalid;
20027 }
20028
20029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(s_version<16) // July 2007
20030 {
20031 if(get_bit(quest_rules,qr_BRANGPICKUP+1))
20032 temp_zinit.hcp_per_hc = 0xFF;
20033
20034 //Dispose of legacy rule
20035 set_bit(quest_rules,qr_BRANGPICKUP+1, 0);
20036 }
20037 62 }
20038
20039
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if(s_version < 29)
20040 {
20041
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_getc(&padding,f,true))
20042 return qe_invalid;
20043 59 temp_zinit.max_bombs = padding;
20044 59 }
20045
20046
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.keys,f,true))
20047 {
20048 return qe_invalid;
20049 }
20050
20051
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_zinit.rupies,f,true))
20052 {
20053 return qe_invalid;
20054 }
20055
20056
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.triforce,f,true))
20057 {
20058 return qe_invalid;
20059 }
20060
20061
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20062 {
20063
2/2
✓ Branch 0 taken 3968 times.
✓ Branch 1 taken 62 times.
4030 for(int32_t i=0; i<64; i++)
20064 {
20065
2/4
✓ Branch 0 taken 3968 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3968 times.
3968 if(!p_getc(&temp_zinit.map[i],f,true))
20066 {
20067 return qe_invalid;
20068 }
20069 3968 }
20070
20071
2/2
✓ Branch 0 taken 3968 times.
✓ Branch 1 taken 62 times.
4030 for(int32_t i=0; i<64; i++)
20072 {
20073
2/4
✓ Branch 0 taken 3968 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3968 times.
3968 if(!p_getc(&temp_zinit.compass[i],f,true))
20074 {
20075 return qe_invalid;
20076 }
20077 3968 }
20078 62 }
20079 else
20080 {
20081 for(int32_t i=0; i<32; i++)
20082 {
20083 if(!p_getc(&temp_zinit.map[i],f,true))
20084 {
20085 return qe_invalid;
20086 }
20087 }
20088
20089 for(int32_t i=0; i<32; i++)
20090 {
20091 if(!p_getc(&temp_zinit.compass[i],f,true))
20092 {
20093 return qe_invalid;
20094 }
20095 }
20096 }
20097
20098
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 if((Header->zelda_version > 0x192)||
20099 //new only
20100 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20101 {
20102
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20103 {
20104
2/2
✓ Branch 0 taken 3968 times.
✓ Branch 1 taken 62 times.
4030 for(int32_t i=0; i<64; i++)
20105 {
20106
2/4
✓ Branch 0 taken 3968 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3968 times.
3968 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20107 {
20108 return qe_invalid;
20109 }
20110 3968 }
20111 62 }
20112 else
20113 {
20114 for(int32_t i=0; i<32; i++)
20115 {
20116 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20117 {
20118 return qe_invalid;
20119 }
20120 }
20121 }
20122 62 }
20123
20124
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 992 times.
1054 for(int32_t i=0; i<16; i++)
20125 {
20126
2/4
✓ Branch 0 taken 992 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 992 times.
992 if(!p_getc(&temp_zinit.misc[i],f,true))
20127 {
20128 return qe_invalid;
20129 }
20130 992 }
20131
20132
1/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 if(s_version < 15) for(int32_t i=0; i<4; i++)
20133 {
20134 if(!p_getc(&sword_hearts[i],f,true))
20135 {
20136 return qe_invalid;
20137 }
20138 }
20139
20140
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.last_map,f,true))
20141 {
20142 return qe_invalid;
20143 }
20144
20145
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.last_screen,f,true))
20146 {
20147 return qe_invalid;
20148 }
20149
20150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(s_version < 14)
20151 {
20152 byte tempmp;
20153
20154 if(!p_getc(&tempmp,f,true))
20155 {
20156 return qe_invalid;
20157 }
20158
20159 temp_zinit.max_magic=tempmp;
20160
20161 if(!p_getc(&tempmp,f,true))
20162 {
20163 return qe_invalid;
20164 }
20165
20166 temp_zinit.magic=tempmp;
20167 }
20168 else
20169 {
20170
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_zinit.max_magic,f,true))
20171 {
20172 return qe_invalid;
20173 }
20174
20175
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_zinit.magic,f,true))
20176 {
20177 return qe_invalid;
20178 }
20179 }
20180
20181
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version < 15)
20182 {
20183 if(s_version < 12)
20184 {
20185 temp_zinit.max_magic*=32;
20186 temp_zinit.magic*=32;
20187 }
20188
20189 for(int32_t i=0; i<4; i++)
20190 {
20191 if(!p_getc(&beam_hearts[i],f,true))
20192 {
20193 return qe_invalid;
20194 }
20195 }
20196
20197 if(!p_getc(&beam_percent,f,true))
20198 {
20199 return qe_invalid;
20200 }
20201 }
20202 else
20203 {
20204
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.bomb_ratio,f,true))
20205 {
20206 return qe_invalid;
20207 }
20208 }
20209
20210
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version < 15)
20211 {
20212 byte tempbp;
20213
20214 for(int32_t i=0; i<4; i++)
20215 {
20216 if(!(s_version < 14 ? p_getc(&tempbp,f,true) : p_igetw(&tempbp,f,true)))
20217 {
20218 return qe_invalid;
20219 }
20220
20221 beam_power[i]=tempbp;
20222 }
20223
20224 if(!p_getc(&hookshot_links,f,true))
20225 {
20226 return qe_invalid;
20227 }
20228
20229 if(s_version>6)
20230 {
20231 if(!p_getc(&hookshot_length,f,true))
20232 {
20233 return qe_invalid;
20234 }
20235
20236 if(!p_getc(&longshot_links,f,true))
20237 {
20238 return qe_invalid;
20239 }
20240
20241 if(!p_getc(&longshot_length,f,true))
20242 {
20243 return qe_invalid;
20244 }
20245 }
20246 }
20247
20248
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.msg_more_x,f,true))
20249 {
20250 return qe_invalid;
20251 }
20252
20253
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.msg_more_y,f,true))
20254 {
20255 return qe_invalid;
20256 }
20257
20258
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.subscreen,f,true))
20259 {
20260 return qe_invalid;
20261 }
20262
20263 //old only
20264
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 if((Header->zelda_version == 0x192)&&(Header->build<174))
20265 {
20266 for(int32_t i=0; i<32; i++)
20267 {
20268 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20269 {
20270 return qe_invalid;
20271 }
20272 }
20273 }
20274
20275
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20276 {
20277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(s_version <= 10)
20278 {
20279 byte tempbyte;
20280
20281 if(!p_getc(&tempbyte,f,true))
20282 {
20283 return qe_invalid;
20284 }
20285
20286 temp_zinit.start_dmap = (word)tempbyte;
20287 }
20288 else
20289 {
20290
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_zinit.start_dmap,f,true))
20291 {
20292 return qe_invalid;
20293 }
20294 }
20295
20296
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.heroAnimationStyle,f,true))
20297 {
20298 return qe_invalid;
20299 }
20300 62 }
20301
20302
3/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 3 times.
62 if(s_version>1 && s_version < 29)
20303 {
20304
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_getc(&padding,f,true))
20305 return qe_invalid;
20306 59 temp_zinit.arrows = padding;
20307
20308
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_getc(&padding,f,true))
20309 return qe_invalid;
20310 59 temp_zinit.max_arrows = padding;
20311 59 }
20312
20313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(s_version>2)
20314 {
20315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(s_version <= 10)
20316 {
20317 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20318 {
20319 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20320 {
20321 return qe_invalid;
20322 }
20323 }
20324 }
20325 else
20326 {
20327
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 62 times.
31806 for(int32_t i=0; i<MAXLEVELS; i++)
20328 {
20329
2/4
✓ Branch 0 taken 31744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31744 times.
✗ Branch 3 not taken.
31744 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20330 {
20331 return qe_invalid;
20332 }
20333 31744 }
20334 }
20335 62 }
20336
20337
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version>3)
20338 {
20339
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_zinit.ss_grid_x,f,true))
20340 {
20341 return qe_invalid;
20342 }
20343
20344
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_zinit.ss_grid_y,f,true))
20345 {
20346 return qe_invalid;
20347 }
20348
20349
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_zinit.ss_grid_xofs,f,true))
20350 {
20351 return qe_invalid;
20352 }
20353
20354
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_zinit.ss_grid_yofs,f,true))
20355 {
20356 return qe_invalid;
20357 }
20358
20359
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_zinit.ss_grid_color,f,true))
20360 {
20361 return qe_invalid;
20362 }
20363
20364
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f,true))
20365 {
20366 return qe_invalid;
20367 }
20368
20369
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f,true))
20370 {
20371 return qe_invalid;
20372 }
20373
20374
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_zinit.ss_flags,f,true))
20375 {
20376 return qe_invalid;
20377 }
20378
20379
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20380
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20381 62 }
20382
20383
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(s_version>4 && s_version<15)
20384 {
20385 if(!p_getc(&moving_fairy_hearts,f,true))
20386 {
20387 return qe_invalid;
20388 }
20389
20390 if(!p_getc(&moving_fairy_heart_percent,f,true))
20391 {
20392 return qe_invalid;
20393 }
20394 }
20395
20396
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(s_version>5 && s_version < 10)
20397 {
20398 if(!p_getc(&temp,f,true))
20399 {
20400 return qe_invalid;
20401 }
20402
20403 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20404 }
20405
20406
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(s_version>6 && s_version<15)
20407 {
20408 if(!p_getc(&stationary_fairy_hearts,f,true))
20409 {
20410 return qe_invalid;
20411 }
20412
20413 if(!p_getc(&stationary_fairy_heart_percent,f,true))
20414 {
20415 return qe_invalid;
20416 }
20417
20418 if(!p_getc(&moving_fairy_magic,f,true))
20419 {
20420 return qe_invalid;
20421 }
20422
20423 if(!p_getc(&moving_fairy_magic_percent,f,true))
20424 {
20425 return qe_invalid;
20426 }
20427
20428 if(!p_getc(&stationary_fairy_magic,f,true))
20429 {
20430 return qe_invalid;
20431 }
20432
20433 if(!p_getc(&stationary_fairy_magic_percent,f,true))
20434 {
20435 return qe_invalid;
20436 }
20437
20438 if(!p_getc(&blue_potion_hearts,f,true))
20439 {
20440 return qe_invalid;
20441 }
20442
20443 if(!p_getc(&blue_potion_heart_percent,f,true))
20444 {
20445 return qe_invalid;
20446 }
20447
20448 if(!p_getc(&red_potion_hearts,f,true))
20449 {
20450 return qe_invalid;
20451 }
20452
20453 if(!p_getc(&red_potion_heart_percent,f,true))
20454 {
20455 return qe_invalid;
20456 }
20457
20458 if(!p_getc(&blue_potion_magic,f,true))
20459 {
20460 return qe_invalid;
20461 }
20462
20463 if(!p_getc(&blue_potion_magic_percent,f,true))
20464 {
20465 return qe_invalid;
20466 }
20467
20468 if(!p_getc(&red_potion_magic,f,true))
20469 {
20470 return qe_invalid;
20471 }
20472
20473 if(!p_getc(&red_potion_magic_percent,f,true))
20474 {
20475 return qe_invalid;
20476 }
20477 }
20478
20479
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version>6)
20480 {
20481
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.subscreen_style,f,true))
20482 {
20483 return qe_invalid;
20484 }
20485 62 }
20486
20487
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version>7)
20488 {
20489
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.usecustomsfx,f,true))
20490 {
20491 return qe_invalid;
20492 }
20493 62 }
20494
20495
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version>8)
20496 {
20497
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_zinit.max_rupees,f,true))
20498 {
20499 return qe_invalid;
20500 }
20501
20502
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_zinit.max_keys,f,true))
20503 {
20504 return qe_invalid;
20505 }
20506 62 }
20507
20508
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version>16)
20509 {
20510
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.gravity,f,true))
20511 {
20512 return qe_invalid;
20513 }
20514
20515
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_igetw(&temp_zinit.terminalv,f,true))
20516 {
20517 return qe_invalid;
20518 }
20519
20520
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.msg_speed,f,true))
20521 {
20522 return qe_invalid;
20523 }
20524
20525
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.transition_type,f,true))
20526 {
20527 return qe_invalid;
20528 }
20529
20530
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f,true))
20531 {
20532 return qe_invalid;
20533 }
20534 62 }
20535
20536
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version>17)
20537 {
20538
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(!p_getc(&temp_zinit.msg_more_is_offset,f,true))
20539 {
20540 return qe_invalid;
20541 }
20542 62 }
20543
20544 //expaned init data for larger values in 2.55
20545
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20546 {
20547
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.bombs,f,true))
20548 {
20549 return qe_invalid;
20550 }
20551
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.super_bombs,f,true))
20552 {
20553 return qe_invalid;
20554 }
20555
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.max_bombs,f,true))
20556 {
20557 return qe_invalid;
20558 }
20559
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.max_sbombs,f,true))
20560 {
20561 return qe_invalid;
20562 }
20563
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.arrows,f,true))
20564 {
20565 return qe_invalid;
20566 }
20567
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.max_arrows,f,true))
20568 {
20569 return qe_invalid;
20570 }
20571
20572 3 }
20573
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if ( s_version >= 20 )
20574 {
20575
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.heroStep,f,true))
20576 {
20577 return qe_invalid;
20578 }
20579 3 }
20580 else
20581 {
20582 59 temp_zinit.heroStep = 150; //1.5 pixels per frame
20583 }
20584
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if ( s_version >= 21 )
20585 {
20586
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.subscrSpeed,f,true))
20587 {
20588 return qe_invalid;
20589 }
20590 3 }
20591 else
20592 {
20593 59 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20594 }
20595 //old only
20596
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 if((Header->zelda_version == 0x192)&&(Header->build<174))
20597 {
20598 byte items2;
20599
20600 if(!p_getc(&items2,f,true))
20601 {
20602 return qe_invalid;
20603 }
20604
20605 temp_zinit.items[iDinsFire]=(get_bit(&items2, idI_DFIRE)!=0);
20606 temp_zinit.items[iFaroresWind]=(get_bit(&items2, idI_FWIND)!=0);
20607 temp_zinit.items[iNayrusLove]=(get_bit(&items2, idI_NLOVE)!=0);
20608 }
20609
20610
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(Header->zelda_version < 0x193)
20611 {
20612 for(int32_t q=0; q<96; q++)
20613 {
20614 if(!p_getc(&padding,f,true))
20615 {
20616 return qe_invalid;
20617 }
20618 }
20619
20620 //new only
20621 if((Header->zelda_version == 0x192)&&(Header->build>173))
20622 {
20623 if(!p_getc(&padding,f,true))
20624 {
20625 return qe_invalid;
20626 }
20627
20628 if(!p_getc(&padding,f,true))
20629 {
20630 return qe_invalid;
20631 }
20632 }
20633 }
20634 62 }
20635
20636
3/6
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
118 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20637 {
20638 //temp_zinit.shield=i_smallshield;
20639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20640
20641 if(sshieldid != -1)
20642 temp_zinit.items[sshieldid] = true;
20643 }
20644
20645
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20646 {
20647 temp_zinit.hc=3;
20648 temp_zinit.start_heart=3;
20649 temp_zinit.cont_heart=3;
20650 temp_zinit.max_bombs=8;
20651 }
20652
20653
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20654 {
20655 sword_hearts[0]=0;
20656 sword_hearts[1]=5;
20657 sword_hearts[2]=12;
20658 sword_hearts[3]=21;
20659 }
20660
20661
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20662 {
20663 temp_zinit.last_map=0;
20664 temp_zinit.last_screen=0;
20665 }
20666
20667
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20668 {
20669 temp_zinit.max_magic=0;
20670 temp_zinit.magic=0;
20671 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20672 }
20673
20674
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20675 {
20676
20677 for(int32_t x=0; x<4; x++)
20678 {
20679 beam_hearts[x]=100;
20680 }
20681
20682 for(int32_t i=0; i<idBP_MAX; i++)
20683 {
20684 set_bit(&beam_percent,i,!get_bit(quest_rules,qr_LENSHINTS+i));
20685 set_bit(quest_rules,qr_LENSHINTS+i,0);
20686 }
20687
20688 for(int32_t x=0; x<4; x++)
20689 {
20690 beam_power[x]=get_bit(quest_rules,qr_HIDECARRIEDITEMS)?50:100;
20691 }
20692
20693 set_bit(quest_rules,qr_HIDECARRIEDITEMS,0);
20694 hookshot_links=100;
20695 temp_zinit.msg_more_x=224;
20696 temp_zinit.msg_more_y=64;
20697 }
20698
20699 // Okay, let's put these legacy values into itemsbuf.
20700
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(s_version < 15)
20701 for(int32_t i=0; i<MAXITEMS; i++)
20702 {
20703 switch(i)
20704 {
20705 case iFairyStill:
20706 itemsbuf[i].misc1 = stationary_fairy_hearts;
20707 itemsbuf[i].misc2 = stationary_fairy_magic;
20708 itemsbuf[i].misc3 = 0;
20709 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20710 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20711 break;
20712
20713 case iFairyMoving:
20714 itemsbuf[i].misc1 = moving_fairy_hearts;
20715 itemsbuf[i].misc2 = moving_fairy_magic;
20716 itemsbuf[i].misc3 = 50;
20717 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20718 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20719 break;
20720
20721 case iRPotion:
20722 itemsbuf[i].misc1 = red_potion_hearts;
20723 itemsbuf[i].misc2 = red_potion_magic;
20724 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20725 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20726 break;
20727
20728 case iBPotion:
20729 itemsbuf[i].misc1 = blue_potion_hearts;
20730 itemsbuf[i].misc2 = blue_potion_magic;
20731 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20732 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20733 break;
20734
20735 case iSword:
20736 itemsbuf[i].pickup_hearts = sword_hearts[0];
20737 itemsbuf[i].misc1 = beam_hearts[0];
20738 itemsbuf[i].misc2 = beam_power[0];
20739 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20740 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20741 break;
20742
20743 case iWSword:
20744 itemsbuf[i].pickup_hearts = sword_hearts[1];
20745 itemsbuf[i].misc1 = beam_hearts[1];
20746 itemsbuf[i].misc2 = beam_power[1];
20747 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20748 break;
20749
20750 case iMSword:
20751 itemsbuf[i].pickup_hearts = sword_hearts[2];
20752 itemsbuf[i].misc1 = beam_hearts[2];
20753 itemsbuf[i].misc2 = beam_power[2];
20754 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20755 break;
20756
20757 case iXSword:
20758 itemsbuf[i].pickup_hearts = sword_hearts[3];
20759 itemsbuf[i].misc1 = beam_hearts[3];
20760 itemsbuf[i].misc2 = beam_power[3];
20761 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20762 break;
20763
20764 case iHookshot:
20765 itemsbuf[i].misc1 = hookshot_length;
20766 itemsbuf[i].misc2 = hookshot_links;
20767 break;
20768
20769 case iLongshot:
20770 itemsbuf[i].misc1 = longshot_length;
20771 itemsbuf[i].misc2 = longshot_links;
20772 break;
20773 }
20774 }
20775
20776
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20777 {
20778 //was new subscreen rule
20779 temp_zinit.subscreen=get_bit(quest_rules,qr_FREEFORM)?1:0;
20780 set_bit(quest_rules,qr_FREEFORM,0);
20781 }
20782
20783
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20784 {
20785 temp_zinit.start_dmap=0;
20786 }
20787
20788
2/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20789 {
20790 temp_zinit.heroAnimationStyle=get_bit(quest_rules,qr_BSZELDA)?1:0;
20791 }
20792
20793
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20794 {
20795 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20796 temp_zinit.max_rupees=999;
20797 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20798 }
20799
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20800 {
20801 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20802 temp_zinit.max_bombs = 8;
20803 }
20804 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20805 //time to ensure that we port all new values properly:
20806
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(Header->zelda_version < 0x250)
20807 {
20808 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20809 }
20810
20811
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version > 21)
20812 {
20813
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.hp_per_heart,f,true))
20814 {
20815 return qe_invalid;
20816 }
20817
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.magic_per_block,f,true))
20818 {
20819 return qe_invalid;
20820 }
20821
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.hero_damage_multiplier,f,true))
20822 {
20823 return qe_invalid;
20824 }
20825
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.ene_damage_multiplier,f,true))
20826 {
20827 return qe_invalid;
20828 }
20829 3 }
20830 else
20831 {
20832 59 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20833 59 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20834 59 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20835 59 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20836 }
20837
20838
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version > 22)
20839 {
20840
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 3 times.
78 for(int32_t q = 0; q < 25; ++q)
20841 {
20842
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 75 times.
75 if(!p_igetw(&temp_zinit.scrcnt[q],f,true))
20843 {
20844 return qe_invalid;
20845 }
20846 75 }
20847
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 3 times.
78 for(int32_t q = 0; q < 25; ++q)
20848 {
20849
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 75 times.
75 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f,true))
20850 {
20851 return qe_invalid;
20852 }
20853 75 }
20854 3 }
20855 else
20856 {
20857
2/2
✓ Branch 0 taken 1475 times.
✓ Branch 1 taken 59 times.
1534 for(int32_t q = 0; q < 25; ++q)
20858 {
20859 1475 temp_zinit.scrcnt[q] = 0;
20860 1475 temp_zinit.scrmaxcnt[q] = 0;
20861 1475 }
20862 }
20863
20864
20865
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version > 23)
20866 {
20867
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.dither_type,f,true))
20868 {
20869 return qe_invalid;
20870 }
20871
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.dither_arg,f,true))
20872 {
20873 return qe_invalid;
20874 }
20875
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.dither_percent,f,true))
20876 {
20877 return qe_invalid;
20878 }
20879
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.def_lightrad,f,true))
20880 {
20881 return qe_invalid;
20882 }
20883
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.transdark_percent,f,true))
20884 {
20885 return qe_invalid;
20886 }
20887 3 }
20888 else
20889 {
20890 59 temp_zinit.dither_type = 0;
20891 59 temp_zinit.dither_arg = 0;
20892 59 temp_zinit.dither_percent = 20;
20893 59 temp_zinit.def_lightrad = 24;
20894 59 temp_zinit.transdark_percent = 0;
20895 }
20896
20897
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version > 24)
20898 {
20899
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.darkcol,f,true))
20900 {
20901 return qe_invalid;
20902 }
20903 3 }
20904 else
20905 {
20906 59 temp_zinit.darkcol = BLACK;
20907 }
20908
20909
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version > 25)
20910 {
20911
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetl(&temp_zinit.gravity2,f,true))
20912 {
20913 return qe_invalid;
20914 }
20915
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetl(&temp_zinit.swimgravity,f,true))
20916 {
20917 return qe_invalid;
20918 }
20919 3 }
20920 else
20921 {
20922 59 temp_zinit.gravity2 = temp_zinit.gravity*100;
20923 59 temp_zinit.swimgravity = 5;
20924 }
20925
20926
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version > 26)
20927 {
20928
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f,true))
20929 {
20930 return qe_invalid;
20931 }
20932
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f,true))
20933 {
20934 return qe_invalid;
20935 }
20936
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f,true))
20937 {
20938 return qe_invalid;
20939 }
20940 3 }
20941 else
20942 {
20943 59 temp_zinit.heroSideswimUpStep = 150;
20944 59 temp_zinit.heroSideswimSideStep = 100;
20945 59 temp_zinit.heroSideswimDownStep = 75;
20946 }
20947
20948
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version > 27)
20949 {
20950
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetl(&temp_zinit.exitWaterJump,f,true))
20951 {
20952 return qe_invalid;
20953 }
20954 3 }
20955 else
20956 {
20957 59 temp_zinit.exitWaterJump = 0;
20958 }
20959
20960
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version > 29)
20961 {
20962
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_igetl(&temp_zinit.bunny_ltm,f,true))
20963 {
20964 return qe_invalid;
20965 }
20966 3 }
20967 else
20968 {
20969 59 temp_zinit.bunny_ltm = 0;
20970 }
20971
20972
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version > 30)
20973 {
20974
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.switchhookstyle,f,true))
20975 {
20976 return qe_invalid;
20977 }
20978 3 }
20979 else
20980 {
20981 59 temp_zinit.switchhookstyle = 1;
20982 }
20983
20984
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 59 times.
62 if(s_version > 31)
20985 {
20986
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp_zinit.magicdrainrate,f,true))
20987 {
20988 return qe_invalid;
20989 }
20990 3 }
20991 else
20992 {
20993
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
20994
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20995 }
20996
20997
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 temp_zinit.clear_genscript();
20998
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 61 times.
62 if(s_version > 32)
20999 {
21000 1 word numgenscript = 0;
21001
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_igetw(&numgenscript,f,true))
21002 return qe_invalid;
21003
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 for(auto q = 1; q < numgenscript; ++q)
21004 {
21005
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getc(&padding,f,true))
21006 return qe_invalid;
21007
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!(padding&2))
21008 continue;
21009 1 temp_zinit.gen_doscript[q] = padding&1;
21010
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetw(&temp_zinit.gen_exitState[q],f,true))
21011 return qe_invalid;
21012
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_igetw(&temp_zinit.gen_reloadState[q],f,true))
21013 return qe_invalid;
21014
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 for(auto p = 0; p < 8; ++p)
21015
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(!p_igetl(&temp_zinit.gen_initd[q][p],f,true))
21016 return qe_invalid;
21017
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_dataSize[q],f,true))
21018 return qe_invalid;
21019
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f,true))
21020 return qe_invalid;
21021
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_eventstate[q],f,true))
21022 return qe_invalid;
21023 1 }
21024 1 }
21025
21026
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(keepdata==true)
21027 {
21028
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 zinit = temp_zinit;
21029
21030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(zinit.heroAnimationStyle==las_zelda3slow)
21031 {
21032 hero_animation_speed=2;
21033 }
21034 else
21035 {
21036 62 hero_animation_speed=1;
21037 }
21038 62 }
21039
21040 62 return 0;
21041 298 }
21042
21043 /*
21044 void setupitemdropsets()
21045 {
21046 for(int32_t i=0; i<isMAX; i++)
21047 {
21048 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21049 }
21050 }
21051 */
21052
21053 62 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build, bool keepdata)
21054 {
21055 62 build=build; // here to prevent compiler warnings
21056 dword dummy_dword;
21057 62 word item_drop_sets_to_read=0;
21058 item_drop_object tempitemdrop;
21059 62 word s_version=0, s_cversion=0;
21060
21061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(keepdata)
21062 {
21063
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21064 {
21065 15872 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21066 15872 }
21067 62 }
21068
21069
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(version > 0x192)
21070 {
21071 62 item_drop_sets_to_read=0;
21072
21073 //section version info
21074
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_version,f,true))
21075 {
21076 return qe_invalid;
21077 }
21078
21079 62 FFCore.quest_format[vItemDropsets] = s_version;
21080
21081 //al_trace("Item drop sets version %d\n", s_version);
21082
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_cversion,f,true))
21083 {
21084 return qe_invalid;
21085 }
21086
21087 //section size
21088
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&dummy_dword,f,true))
21089 {
21090 return qe_invalid;
21091 }
21092
21093 //finally... section data
21094
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&item_drop_sets_to_read,f,true))
21095 {
21096 return qe_invalid;
21097 }
21098 62 }
21099 else
21100 {
21101 if(keepdata==true)
21102 {
21103 init_item_drop_sets();
21104 }
21105 }
21106
21107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(s_version>=1)
21108 {
21109
2/2
✓ Branch 0 taken 1219 times.
✓ Branch 1 taken 62 times.
1281 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21110 {
21111
1/2
✓ Branch 0 taken 1219 times.
✗ Branch 1 not taken.
1219 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f,true))
21112 {
21113 return qe_invalid;
21114 }
21115
21116
2/2
✓ Branch 0 taken 12190 times.
✓ Branch 1 taken 1219 times.
13409 for(int32_t j=0; j<10; ++j)
21117 {
21118
1/2
✓ Branch 0 taken 12190 times.
✗ Branch 1 not taken.
12190 if(!p_igetw(&tempitemdrop.item[j],f,true))
21119 {
21120 return qe_invalid;
21121 }
21122 12190 }
21123
21124
2/2
✓ Branch 0 taken 13409 times.
✓ Branch 1 taken 1219 times.
14628 for(int32_t j=0; j<11; ++j)
21125 {
21126
1/2
✓ Branch 0 taken 13409 times.
✗ Branch 1 not taken.
13409 if(!p_igetw(&tempitemdrop.chance[j],f,true))
21127 {
21128 return qe_invalid;
21129 }
21130 13409 }
21131
21132 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21133 // overrides the quest's set #12.
21134
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1219 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1219 if(s_version<2 && i==12)
21135 continue;
21136
21137 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21138
1/4
✓ Branch 0 taken 1219 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1219 if(s_version<2) for(int32_t j=0; j<10; ++j)
21139 {
21140 int32_t it = tempitemdrop.item[j];
21141
21142 if((itemsbuf[it].family == itype_rupee
21143 && ((itemsbuf[it].amount)&0xFFF) == 10)
21144 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21145 {
21146 tempitemdrop.chance[j+1]=0;
21147 }
21148 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21149 {
21150 tempitemdrop.chance[j+1]=0;
21151 }
21152
21153 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21154 if(itemsbuf[it].family == itype_misc)
21155 {
21156 // If a non-gameplay item was selected, then item drop was aborted.
21157 // Reflect this by increasing the 'Nothing' chance accordingly.
21158 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21159 tempitemdrop.chance[j+1]=0;
21160 }
21161 }
21162
21163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1219 times.
1219 if(keepdata)
21164 {
21165 1219 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21166 1219 }
21167 1219 }
21168 62 }
21169
21170 62 return 0;
21171 62 }
21172
21173 62 int32_t readfavorites(PACKFILE *f, int32_t, word, bool keepdata)
21174 {
21175 int32_t temp_num;
21176 dword dummy_dword;
21177 word num_favorite_combos;
21178 word num_favorite_combo_aliases;
21179 62 word s_version=0, s_cversion=0;
21180
21181 //section version info
21182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(!p_igetw(&s_version,f,true))
21183 {
21184 return qe_invalid;
21185 }
21186
21187 62 FFCore.quest_format[vFavourites] = s_version;
21188
21189
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&s_cversion,f,true))
21190 {
21191 return qe_invalid;
21192 }
21193
21194 //section size
21195
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetl(&dummy_dword,f,true))
21196 {
21197 return qe_invalid;
21198 }
21199
21200 //finally... section data
21201
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&num_favorite_combos,f,true))
21202 {
21203 return qe_invalid;
21204 }
21205
21206
2/2
✓ Branch 0 taken 6200 times.
✓ Branch 1 taken 62 times.
6262 for(int32_t i=0; i<num_favorite_combos; i++)
21207 {
21208
1/2
✓ Branch 0 taken 6200 times.
✗ Branch 1 not taken.
6200 if(!p_igetl(&temp_num,f,true))
21209 {
21210 return qe_invalid;
21211 }
21212
21213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6200 times.
6200 if(keepdata)
21214 {
21215 6200 favorite_combos[i]=temp_num;
21216 6200 }
21217 6200 }
21218
21219
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_igetw(&num_favorite_combo_aliases,f,true))
21220 {
21221 return qe_invalid;
21222 }
21223
21224
2/2
✓ Branch 0 taken 6200 times.
✓ Branch 1 taken 62 times.
6262 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21225 {
21226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6200 times.
6200 if(!p_igetl(&temp_num,f,true))
21227 {
21228 return qe_invalid;
21229 }
21230
21231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6200 times.
6200 if(keepdata)
21232 {
21233 6200 favorite_comboaliases[i]=temp_num;
21234 6200 }
21235 6200 }
21236
21237 62 return 0;
21238 62 }
21239
21240 /*
21241 switch (ret) {
21242 case 0:
21243 break;
21244
21245 case qe_invalid:
21246 goto invalid;
21247 break;
21248 default:
21249 pack_fclose(f);
21250 if(!oldquest)
21251 delete_file(tmpfilename);
21252 return ret;
21253 break;
21254 }
21255 */
21256
21257 const char *skip_text[skip_max]=
21258 {
21259 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21260 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21261 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21262 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21263 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21264 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21265 "skip_favorites"
21266 };
21267
21268
21269 void port250QuestRules(){
21270
21271 portCandleRules(); //Candle
21272 portBombRules();
21273
21274 }
21275
21276 void portCandleRules()
21277 {
21278 bool hurtshero = get_bit(quest_rules,qr_FIREPROOFHERO);
21279 //itemdata itemsbuf;
21280 for ( int32_t q = 0; q < MAXITEMS; q++ )
21281 {
21282 if ( itemsbuf[q].family == itype_candle )
21283 {
21284 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21285 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21286 }
21287 }
21288 }
21289
21290 void portBombRules()
21291 {
21292 bool hurtshero = get_bit(quest_rules,qr_OUCHBOMBS);
21293 //itemdata itemsbuf;
21294 for ( int32_t q = 0; q < MAXITEMS; q++ )
21295 {
21296 if ( itemsbuf[q].family == itype_bomb )
21297 {
21298 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21299 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21300 }
21301 }
21302
21303 }
21304
21305 //Internal function for loadquest wrapper
21306 62 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool compressed, bool encrypted, bool keepall, const byte *skip_flags, byte printmetadata)
21307 {
21308 62 DMapEditorLastMaptileUsed = 0;
21309 62 combosread=false;
21310 62 mapsread=false;
21311 62 fixffcs=false;
21312
21313
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if(get_debug()&&(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
21314 {
21315 keepall=false;
21316 jwin_alert("Load Quest","Data retention disabled.",NULL,NULL,"OK",NULL,13,27,lfont);
21317 }
21318
21319 // show_progress=true;
21320 char tmpfilename[L_tmpnam];
21321 62 temp_name(tmpfilename);
21322 // char percent_done[30];
21323 62 bool catchup=false;
21324 byte tempbyte;
21325 62 word old_map_count=map_count;
21326
21327 62 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21328 62 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21329 62 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21330
21331
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(keepall==false||get_bit(skip_flags, skip_rules))
21332 {
21333 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21334 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21335 }
21336
21337 62 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21338 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21339
21340
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(keepall==false||get_bit(skip_flags, skip_midis))
21341 {
21342 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21343 }
21344
21345
21346
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(keepall&&!get_bit(skip_flags, skip_ffscript))
21347 {
21348 62 zScript.clear();
21349 62 globalmap.clear();
21350 62 genericmap.clear();
21351 62 ffcmap.clear();
21352 62 itemmap.clear();
21353 62 npcmap.clear();
21354 62 ewpnmap.clear();
21355 62 lwpnmap.clear();
21356 62 playermap.clear();
21357 62 dmapmap.clear();
21358 62 screenmap.clear();
21359 62 itemspritemap.clear();
21360 62 comboscriptmap.clear();
21361
21362
2/2
✓ Branch 0 taken 31682 times.
✓ Branch 1 taken 62 times.
31744 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21363 {
21364 31682 ffcmap[i].clear();
21365 31682 }
21366
21367 62 globalmap[0].slotname = "Slot 1:";
21368 62 globalmap[0].scriptname = "~Init";
21369 62 globalmap[0].update();
21370
21371
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 62 times.
496 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21372 {
21373 434 globalmap[i].clear();
21374 434 }
21375
21376
2/2
✓ Branch 0 taken 15810 times.
✓ Branch 1 taken 62 times.
15872 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21377 {
21378 15810 itemmap[i].clear();
21379 15810 }
21380
21381 //new script types -- prevent carrying over to a quest that you load after reading them
21382 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21383
2/2
✓ Branch 0 taken 15810 times.
✓ Branch 1 taken 62 times.
15872 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21384 {
21385 15810 npcmap[i].clear();
21386 15810 }
21387
2/2
✓ Branch 0 taken 15810 times.
✓ Branch 1 taken 62 times.
15872 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21388 {
21389 15810 lwpnmap[i].clear();
21390 15810 }
21391
2/2
✓ Branch 0 taken 15810 times.
✓ Branch 1 taken 62 times.
15872 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21392 {
21393 15810 ewpnmap[i].clear();
21394 15810 }
21395
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 62 times.
310 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21396 {
21397 248 playermap[i].clear();
21398 248 }
21399
2/2
✓ Branch 0 taken 15810 times.
✓ Branch 1 taken 62 times.
15872 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21400 {
21401 15810 dmapmap[i].clear();
21402 15810 }
21403
2/2
✓ Branch 0 taken 15810 times.
✓ Branch 1 taken 62 times.
15872 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21404 {
21405 15810 screenmap[i].clear();
21406 15810 }
21407
2/2
✓ Branch 0 taken 15810 times.
✓ Branch 1 taken 62 times.
15872 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21408 {
21409 15810 itemspritemap[i].clear();
21410 15810 }
21411
2/2
✓ Branch 0 taken 31682 times.
✓ Branch 1 taken 62 times.
31744 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21412 {
21413 31682 comboscriptmap[i].clear();
21414 31682 }
21415
2/2
✓ Branch 0 taken 31682 times.
✓ Branch 1 taken 62 times.
31744 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21416 {
21417 31682 genericmap[i].clear();
21418 31682 }
21419
21420 62 reset_scripts();
21421 62 }
21422
21423 zquestheader tempheader;
21424 62 memset(&tempheader, 0, sizeof(zquestheader));
21425 62 zinfo tempzi;
21426 62 tempzi.clear();
21427 62 load_tmp_zi = &tempzi;
21428
21429 // oldquest flag is set when an unencrypted qst file is suspected.
21430 62 bool oldquest = false;
21431 62 int32_t open_error=0;
21432 char deletefilename[1024];
21433 62 PACKFILE *f=open_quest_file(&open_error, filename, deletefilename, compressed, encrypted, show_progress);
21434
21435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(!f)
21436 return open_error;
21437 char zinfofilename[2048];
21438 62 replace_extension(zinfofilename, filename, "zinfo", 2047);
21439 62 int32_t ret=0;
21440
21441 //header
21442 62 box_out("Reading Header...");
21443 62 ret=readheader(f, &tempheader, true, printmetadata);
21444
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21445 62 box_out("okay.");
21446 62 box_eol();
21447
21448
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3 times.
62 if(read_zinfo)
21449 {
21450 3 box_out("Reading ZInfo - ");
21451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 box_out(read_ext_zinfo ? "External..." : "Internal...");
21452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(read_ext_zinfo)
21453 {
21454 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21455 ret=readzinfo(inf, tempzi, tempheader);
21456 if(inf) pack_fclose(inf);
21457 checkstatus(ret);
21458 }
21459 else
21460 {
21461 3 ret=readzinfo(f, tempzi, tempheader);
21462
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
3 checkstatus(ret);
21463 }
21464 3 box_out("okay.");
21465 3 box_eol();
21466 3 }
21467
21468
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(tempheader.zelda_version>=0x193)
21469 {
21470 dword section_id;
21471
21472 //section id
21473
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(!p_mgetl(&section_id,f,true))
21474 {
21475 return qe_invalid;
21476 }
21477
21478
2/2
✓ Branch 0 taken 1488 times.
✓ Branch 1 taken 62 times.
1550 while(!pack_feof(f))
21479 {
21480
24/25
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 62 times.
✓ Branch 6 taken 62 times.
✓ Branch 7 taken 62 times.
✓ Branch 8 taken 62 times.
✓ Branch 9 taken 62 times.
✓ Branch 10 taken 62 times.
✓ Branch 11 taken 62 times.
✓ Branch 12 taken 62 times.
✓ Branch 13 taken 62 times.
✓ Branch 14 taken 62 times.
✓ Branch 15 taken 62 times.
✓ Branch 16 taken 62 times.
✓ Branch 17 taken 62 times.
✓ Branch 18 taken 62 times.
✓ Branch 19 taken 62 times.
✓ Branch 20 taken 62 times.
✓ Branch 21 taken 62 times.
✓ Branch 22 taken 62 times.
✓ Branch 23 taken 62 times.
✓ Branch 24 taken 62 times.
1488 switch(section_id)
21481 {
21482 case ID_RULES:
21483
21484 //rules
21485
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21486 {
21487 box_out("found.");
21488 box_eol();
21489 catchup=false;
21490 }
21491
21492 62 box_out("Reading Rules...");
21493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21494
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21495 62 box_out("okay.");
21496 62 box_eol();
21497 62 break;
21498
21499 case ID_STRINGS:
21500
21501 //strings
21502
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21503 {
21504 box_out("found.");
21505 box_eol();
21506 catchup=false;
21507 }
21508
21509 62 box_out("Reading Strings...");
21510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21511
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21512 62 box_out("okay.");
21513 62 box_eol();
21514 62 break;
21515
21516 case ID_MISC:
21517
21518 //misc data
21519
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21520 {
21521 box_out("found.");
21522 box_eol();
21523 catchup=false;
21524 }
21525
21526 62 box_out("Reading Misc. Data...");
21527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21528
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21529 62 box_out("okay.");
21530 62 box_eol();
21531 62 break;
21532
21533 case ID_TILES:
21534
21535 //tiles
21536
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21537 {
21538 box_out("found.");
21539 box_eol();
21540 catchup=false;
21541 }
21542
21543 62 box_out("Reading Tiles...");
21544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
21545
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21546 62 box_out("okay.");
21547 62 box_eol();
21548 62 break;
21549
21550 case ID_COMBOS:
21551
21552 //combos
21553
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21554 {
21555 box_out("found.");
21556 box_eol();
21557 catchup=false;
21558 }
21559
21560 62 box_out("Reading Combos...");
21561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
21562 62 combosread=true;
21563
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21564 62 box_out("okay.");
21565 62 box_eol();
21566 62 break;
21567
21568 case ID_COMBOALIASES:
21569
21570 //combo aliases
21571
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21572 {
21573 box_out("found.");
21574 box_eol();
21575 catchup=false;
21576 }
21577
21578 62 box_out("Reading Combo Aliases...");
21579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_comboaliases));
21580
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21581 62 box_out("okay.");
21582 62 box_eol();
21583 62 break;
21584
21585 case ID_CSETS:
21586
21587 //color data
21588
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21589 {
21590 box_out("found.");
21591 box_eol();
21592 catchup=false;
21593 }
21594
21595 62 box_out("Reading Color Data...");
21596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
21597
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21598 62 box_out("okay.");
21599 62 box_eol();
21600 62 break;
21601
21602 case ID_MAPS:
21603
21604 //maps
21605
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21606 {
21607 box_out("found.");
21608 box_eol();
21609 catchup=false;
21610 }
21611
21612 62 box_out("Reading Maps...");
21613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
21614 62 mapsread=true;
21615
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21616 62 box_out("okay.");
21617 62 box_eol();
21618 62 break;
21619
21620 case ID_DMAPS:
21621
21622 //dmaps
21623
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21624 {
21625 box_out("found.");
21626 box_eol();
21627 catchup=false;
21628 }
21629
21630 62 box_out("Reading DMaps...");
21631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21632
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21633 62 box_out("okay.");
21634 62 box_eol();
21635 62 break;
21636
21637 case ID_DOORS:
21638
21639 //door combo sets
21640
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21641 {
21642 box_out("found.");
21643 box_eol();
21644 catchup=false;
21645 }
21646
21647 62 box_out("Reading Doors...");
21648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21649
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21650 62 box_out("okay.");
21651 62 box_eol();
21652 62 break;
21653
21654 case ID_ITEMS:
21655
21656 //items
21657
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21658 {
21659 box_out("found.");
21660 box_eol();
21661 catchup=false;
21662 }
21663
21664 62 box_out("Reading Items...");
21665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
21666
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21667
21668 62 box_out("okay.");
21669 62 box_eol();
21670 62 break;
21671
21672 case ID_WEAPONS:
21673
21674 //weapons
21675
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21676 {
21677 box_out("found.");
21678 box_eol();
21679 catchup=false;
21680 }
21681
21682 62 box_out("Reading Weapons...");
21683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
21684
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21685 62 box_out("okay.");
21686 62 box_eol();
21687 62 break;
21688
21689 case ID_COLORS:
21690
21691 //misc. colors
21692
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21693 {
21694 box_out("found.");
21695 box_eol();
21696 catchup=false;
21697 }
21698
21699 62 box_out("Reading Misc. Colors...");
21700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readmisccolors(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_colors));
21701
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21702 62 box_out("okay.");
21703 62 box_eol();
21704 62 break;
21705
21706 case ID_ICONS:
21707
21708 //game icons
21709
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21710 {
21711 box_out("found.");
21712 box_eol();
21713 catchup=false;
21714 }
21715
21716 62 box_out("Reading Game Icons...");
21717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readgameicons(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_icons));
21718
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21719 62 box_out("okay.");
21720 62 box_eol();
21721 62 break;
21722
21723 case ID_INITDATA:
21724
21725 //initialization data
21726
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21727 {
21728 box_out("found.");
21729 box_eol();
21730 catchup=false;
21731 }
21732
21733 62 box_out("Reading Init. Data...");
21734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
21735
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21736 62 box_out("okay.");
21737 62 box_eol();
21738
21739
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(keepall&&!get_bit(skip_flags, skip_subscreens))
21740 {
21741
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 13 times.
62 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21742 {
21743 13 setupsubscreens();
21744
21745
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 13 times.
6669 for(int32_t i=0; i<MAXDMAPS; ++i)
21746 {
21747 6656 int32_t type=DMaps[i].type&dmfTYPE;
21748
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 6643 times.
6656 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21749 6656 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
21750 6656 }
21751 13 }
21752 62 }
21753
21754
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(keepall&&!get_bit(skip_flags, skip_sfx))
21755 {
21756 62 setupsfx();
21757 62 }
21758
21759
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(keepall&&!get_bit(skip_flags, skip_itemdropsets))
21760 {
21761 62 init_item_drop_sets();
21762 62 }
21763
21764
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(keepall&&!get_bit(skip_flags, skip_favorites))
21765 {
21766 62 init_favorites();
21767 62 }
21768
21769 62 break;
21770
21771 case ID_GUYS:
21772
21773 //guys
21774
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21775 {
21776 box_out("found.");
21777 box_eol();
21778 catchup=false;
21779 }
21780
21781 62 box_out("Reading Custom Guy Data...");
21782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
21783
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21784 62 box_out("okay.");
21785 62 box_eol();
21786 62 break;
21787
21788 case ID_HEROSPRITES:
21789
21790 //player sprites
21791
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21792 {
21793 box_out("found.");
21794 box_eol();
21795 catchup=false;
21796 }
21797
21798 62 box_out("Reading Custom Player Sprite Data...");
21799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readherosprites(f, &tempheader, keepall&&!get_bit(skip_flags, skip_herosprites));
21800
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21801 62 box_out("okay.");
21802 62 box_eol();
21803 62 break;
21804
21805 case ID_SUBSCREEN:
21806
21807 //custom subscreens
21808
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21809 {
21810 box_out("found.");
21811 box_eol();
21812 catchup=false;
21813 }
21814
21815 62 box_out("Reading Custom Subscreen Data...");
21816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readsubscreens(f, &tempheader, keepall&&!get_bit(skip_flags, skip_subscreens));
21817
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21818 62 box_out("okay.");
21819 62 box_eol();
21820 62 break;
21821
21822 case ID_FFSCRIPT:
21823
21824 //Freeform combo scripts
21825
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21826 {
21827 box_out("found.");
21828 box_eol();
21829 catchup=false;
21830 }
21831
21832 62 box_out("Reading FF Script Data...");
21833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readffscript(f, &tempheader, keepall&&!get_bit(skip_flags, skip_ffscript));
21834
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21835 62 box_out("okay.");
21836 62 box_eol();
21837 62 break;
21838
21839 case ID_SFX:
21840
21841 //SFX data
21842
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21843 {
21844 box_out("found.");
21845 box_eol();
21846 catchup=false;
21847 }
21848
21849 62 box_out("Reading SFX Data...");
21850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readsfx(f, &tempheader, keepall&&!get_bit(skip_flags, skip_sfx));
21851
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21852 62 box_out("okay.");
21853 62 box_eol();
21854 62 break;
21855
21856 case ID_MIDIS:
21857
21858 //midis
21859
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21860 {
21861 box_out("found.");
21862 box_eol();
21863 catchup=false;
21864 }
21865
21866 62 box_out("Reading Tunes...");
21867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
21868
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21869 62 box_out("okay.");
21870 62 box_eol();
21871 62 break;
21872
21873 case ID_CHEATS:
21874
21875 //cheat codes
21876
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21877 {
21878 box_out("found.");
21879 box_eol();
21880 catchup=false;
21881 }
21882
21883 62 box_out("Reading Cheat Codes...");
21884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
21885
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21886 62 box_out("okay.");
21887 62 box_eol();
21888 62 break;
21889
21890 case ID_ITEMDROPSETS:
21891
21892 //item drop sets
21893
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21894 {
21895 box_out("found.");
21896 box_eol();
21897 catchup=false;
21898 }
21899
21900 62 box_out("Reading Item Drop Sets...");
21901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_itemdropsets));
21902
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21903 62 box_out("okay.");
21904 62 box_eol();
21905 62 break;
21906
21907 case ID_FAVORITES:
21908
21909 //favorite combos and combo aliases
21910
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(catchup)
21911 {
21912 box_out("found.");
21913 box_eol();
21914 catchup=false;
21915 }
21916
21917 62 box_out("Reading Favorite Combos...");
21918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 ret=readfavorites(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_favorites));
21919
1/5
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
62 checkstatus(ret);
21920 62 box_out("okay.");
21921 62 box_eol();
21922 62 break;
21923
21924 default:
21925 if(!catchup)
21926 {
21927 box_out("Bad token! Searching...");
21928 box_eol();
21929 }
21930
21931 catchup=true;
21932 break;
21933 }
21934
21935
21936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1488 times.
1488 if(catchup)
21937 {
21938 //section id
21939 section_id=(section_id<<8);
21940
21941 if(!p_getc(&tempbyte,f,true))
21942 {
21943 return qe_invalid;
21944 }
21945
21946 section_id+=tempbyte;
21947 }
21948
21949 else
21950 {
21951 //section id
21952
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 1426 times.
1488 if(!pack_feof(f))
21953 {
21954
1/2
✓ Branch 0 taken 1426 times.
✗ Branch 1 not taken.
1426 if(!p_mgetl(&section_id,f,true))
21955 {
21956 return qe_invalid;
21957 }
21958 1426 }
21959 }
21960 }
21961 62 }
21962 else
21963 {
21964 //rules
21965 box_out("Reading Rules...");
21966 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21967 checkstatus(ret);
21968 box_out("okay.");
21969 box_eol();
21970
21971 //strings
21972 box_out("Reading Strings...");
21973 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21974 checkstatus(ret);
21975 box_out("okay.");
21976 box_eol();
21977
21978 //door combo sets
21979 box_out("Reading Doors...");
21980 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21981 checkstatus(ret);
21982 box_out("okay.");
21983 box_eol();
21984
21985 //dmaps
21986 box_out("Reading DMaps...");
21987 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21988 checkstatus(ret);
21989 box_out("okay.");
21990 box_eol();
21991
21992 // misc data
21993 box_out("Reading Misc. Data...");
21994 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21995 checkstatus(ret);
21996 box_out("okay.");
21997 box_eol();
21998
21999 //items
22000 box_out("Reading Items...");
22001 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
22002 checkstatus(ret);
22003 box_out("okay.");
22004 box_eol();
22005
22006 //weapons
22007 box_out("Reading Weapons...");
22008 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
22009 checkstatus(ret);
22010 box_out("okay.");
22011 box_eol();
22012
22013 //guys
22014 box_out("Reading Custom Guy Data...");
22015 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
22016 checkstatus(ret);
22017 box_out("okay.");
22018 box_eol();
22019
22020 //maps
22021 box_out("Reading Maps...");
22022 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
22023 mapsread=true;
22024 checkstatus(ret);
22025 box_out("okay.");
22026 box_eol();
22027
22028 //combos
22029 box_out("Reading Combos...");
22030 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
22031 combosread=true;
22032 checkstatus(ret);
22033 box_out("okay.");
22034 box_eol();
22035
22036 //color data
22037 box_out("Reading Color Data...");
22038 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
22039 checkstatus(ret);
22040 box_out("okay.");
22041 box_eol();
22042
22043 //tiles
22044 box_out("Reading Tiles...");
22045 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
22046 checkstatus(ret);
22047 box_out("okay.");
22048 box_eol();
22049
22050 //midis
22051 box_out("Reading Tunes...");
22052 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
22053 checkstatus(ret);
22054 box_out("okay.");
22055 box_eol();
22056
22057 //cheat codes
22058 box_out("Reading Cheat Codes...");
22059 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
22060 checkstatus(ret);
22061 box_out("okay.");
22062 box_eol();
22063
22064 //initialization data
22065 box_out("Reading Init. Data...");
22066 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
22067 checkstatus(ret);
22068 box_out("okay.");
22069 box_eol();
22070
22071 if(keepall&&!get_bit(skip_flags, skip_subscreens))
22072 {
22073 setupsubscreens();
22074
22075 for(int32_t i=0; i<MAXDMAPS; ++i)
22076 {
22077 int32_t type=DMaps[i].type&dmfTYPE;
22078 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22079 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
22080 }
22081 }
22082
22083 box_out("Setting Up Default Sound Effects...");
22084
22085 if(keepall&&!get_bit(skip_flags, skip_sfx))
22086 setupsfx();
22087
22088 box_out("okay.");
22089 box_eol();
22090
22091 //player sprites
22092 box_out("Reading Custom Player Sprite Data...");
22093 ret=readherosprites2(f, -1, 0, keepall&&!get_bit(skip_flags, skip_herosprites));
22094 checkstatus(ret);
22095 box_out("okay.");
22096 box_eol();
22097
22098 box_out("Setting Up Default Item Drop Sets...");
22099 ret=readitemdropsets(f, -1, 0, keepall&&!get_bit(skip_flags, skip_itemdropsets));
22100 box_out("okay.");
22101 box_eol();
22102 }
22103
22104 62 init_spritelists();
22105
22106 // check data
22107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(f)
22108 {
22109 62 pack_fclose(f);
22110 62 }
22111
22112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(!oldquest)
22113 {
22114
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(exists(tmpfilename))
22115 {
22116 delete_file(tmpfilename);
22117 }
22118 62 }
22119
22120
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62 if(fixffcs && combosread && mapsread)
22121 {
22122 for(int32_t i=0; i<map_count; i++)
22123 {
22124 for(int32_t j=0; j<MAPSCRS; j++)
22125 {
22126 for(int32_t m=0; m<32; m++)
22127 {
22128 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22129 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22130 }
22131 }
22132 }
22133 }
22134
22135
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 13 times.
62 if(get_bit(quest_rules, qr_CONTFULL_DEP))
22136 {
22137 13 set_bit(quest_rules, qr_CONTFULL_DEP, 0);
22138 13 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22139 13 zinit.cont_heart=100;
22140 13 zinit.start_heart=zinit.hc;
22141 13 }
22142
22143 62 box_out("Done.");
22144 62 box_eol();
22145 62 box_end(false);
22146
22147 // if (keepall==true||!get_bit(skip_flags, skip_header))
22148
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(keepall&&!get_bit(skip_flags, skip_header))
22149 {
22150 62 memcpy(Header, &tempheader, sizeof(tempheader));
22151 62 }
22152
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(keepall&&!get_bit(skip_flags, skip_zinfo))
22153 {
22154 62 ZI.copyFrom(tempzi);
22155 62 }
22156
22157
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(!keepall||get_bit(skip_flags, skip_maps))
22158 {
22159 map_count=old_map_count;
22160 }
22161
22162
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(!keepall||get_bit(skip_flags, skip_rules))
22163 {
22164 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22165 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22166 }
22167
22168
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(!keepall||get_bit(skip_flags, skip_midis))
22169 {
22170 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22171 }
22172
22173
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 if(deletefilename[0] && exists(deletefilename))
22174 {
22175 62 delete_file(deletefilename);
22176 62 }
22177
22178 //Debug FFCore.quest_format[]
22179 62 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
22180 62 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
22181 62 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
22182 62 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
22183 62 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22184 62 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22185 62 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22186 62 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22187 62 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22188 62 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22189 62 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22190 62 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22191 62 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22192 62 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22193 62 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22194 62 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22195 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22196 62 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22197 62 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22198 62 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22199 62 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22200 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22201 62 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22202 62 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22203 62 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22204 62 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22205 62 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22206 62 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22207 62 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22208 62 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22209 //Print metadata for versions under 2.10 here. Bleah.
22210
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if( FFCore.quest_format[vZelda] < 0x210 )
22211 {
22212 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22213
22214 switch(FFCore.quest_format[vZelda])
22215 {
22216 case 0x193:
22217 {
22218 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22219 }
22220 case 0x192:
22221 {
22222 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22223 }
22224 case 0x190:
22225 {
22226 zprint2("Last saved in ZC Editor Version: 1.90");
22227 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22228 else zprint2("\n");
22229 break;
22230 }
22231 case 0x188:
22232 {
22233 zprint2("Last saved in ZC Editor Version: 1.88");
22234 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22235 else zprint2("\n");
22236 break;
22237 }
22238 case 0x187:
22239 {
22240 zprint2("Last saved in ZC Editor Version: 1.87");
22241 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22242 else zprint2("\n");
22243 break;
22244 }
22245 case 0x186:
22246 {
22247 zprint2("Last saved in ZC Editor Version: 1.86");
22248 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22249 else zprint2("\n");
22250 break;
22251 }
22252 case 0x185:
22253 {
22254 zprint2("Last saved in ZC Editor Version: 1.85");
22255 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22256 else zprint2("\n");
22257 break;
22258 }
22259 case 0x184:
22260 {
22261 zprint2("Last saved in ZC Editor Version: 1.84");
22262 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22263 else zprint2("\n");
22264 break;
22265 }
22266 case 0x183:
22267 {
22268 zprint2("Last saved in ZC Editor Version: 1.83");
22269 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22270 else zprint2("\n");
22271 break;
22272 }
22273 case 0x182:
22274 {
22275 zprint2("Last saved in ZC Editor Version: 1.82");
22276 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22277 else zprint2("\n");
22278 break;
22279 }
22280 case 0x181:
22281 {
22282 zprint2("Last saved in ZC Editor Version: 1.81");
22283 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22284 else zprint2("\n");
22285 break;
22286 }
22287 case 0x180:
22288 {
22289 zprint2("Last saved in ZC Editor Version: 1.80");
22290 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22291 else zprint2("\n");
22292 break;
22293 }
22294 default:
22295 {
22296 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22297 }
22298 }
22299 }
22300
22301 62 return qe_OK;
22302
22303 invalid:
22304 box_out("error.");
22305 box_eol();
22306 box_end(true);
22307
22308 if(f)
22309 {
22310 pack_fclose(f);
22311 }
22312
22313 if(!oldquest)
22314 {
22315 if(exists(tmpfilename))
22316 {
22317 delete_file(tmpfilename);
22318 }
22319
22320 if(deletefilename[0] && exists(deletefilename))
22321 {
22322 delete_file(deletefilename);
22323 }
22324 }
22325
22326 return qe_invalid;
22327
22328 62 }
22329
22330 62 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool compressed, bool encrypted, bool keepall, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22331 {
22332 62 loading_qst_name = filename;
22333 62 loading_qst_num = qst_num;
22334 62 loadquest_report = report;
22335 62 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, compressed, encrypted, keepall, skip_flags,printmetadata);
22336 62 load_tmp_zi = NULL;
22337 62 loading_qst_name = NULL;
22338 62 loadquest_report = false;
22339 62 loading_qst_num = 0;
22340 62 return ret;
22341 }
22342 /*** end of qst.cc ***/
22343
22344